compiler: Fix identifier normalization function

`__1` is a valid identifier, which we normalized to
`--1`, which is invalid.

This changes the nromalization function to leave a `_` in the first position.
This commit is contained in:
Tobias Hunger 2025-05-20 15:21:03 +00:00 committed by Tobias Hunger
parent 6e4e98af4e
commit 63f7533dc9
7 changed files with 84 additions and 55 deletions

View file

@ -461,8 +461,15 @@ function loadSlint(loadData: LoadData): Object {
// globals
instance!.definition().globals.forEach((globalName) => {
if (componentHandle[globalName] !== undefined) {
console.warn("Duplicated property name " + globalName);
const jsName = translateName(globalName);
if (componentHandle[jsName] !== undefined) {
console.warn(
"Duplicated property name " +
globalName +
" (In JS: " +
jsName +
")",
);
} else {
const globalObject = Object.create({});
@ -576,7 +583,7 @@ function loadSlint(loadData: LoadData): Object {
}
});
Object.defineProperty(componentHandle, globalName, {
Object.defineProperty(componentHandle, jsName, {
get() {
return globalObject;
},