boa
boa copied to clipboard
Reserved word (keyword) as identifier and object properties
Describe the bug Boa throws syntax error when using some reserved words as variable names, function arguments, and object property.
To Reproduce
let o = { false: 100 };
o.false; // syntax error, should work
Another related bug:
function f(await, x) {
return await + x; // syntax error, should work
}
f(1, 2);
After the Unicode escapes in identifier name are supported, the following code should also work properly:
let o = { f\u{61}lse: 10}; // should work
o.f\u{61}lse; // should work
let x = f\u{61}lse; // should throw syntax error, keyword cannot contain unicode escapes
Expected behavior As mentioned above.
Additional context The Identifier syntax defined in ECMAscript is not properly implemented. Reference: https://tc39.es/ecma262/#sec-identifiers
I am working on this issue.
The Unicode escape in identifier name (lexer) is supported in #1102 , but this issue seems to be a bug across both the lexer and parser - the keyword should be evaluated in parser based on where it appears instead of the lexer. I will create a separate PR for it since it will be big and it is more suitable to be addressed the bug separately.
I am working on this issue.
The Unicode escape in identifier name (lexer) is supported in #1102 , but this issue seems to be a bug across both the lexer and parser - the keyword should be evaluated in parser based on where it appears instead of the lexer. I will create a separate PR for it since it will be big and it is more suitable to be addressed the bug separately.
Is this fixed now?
The first example still throws a syntax error. The second throws no errors. The third example incorrectly errors for the first two lines.
Everything has been solved, except for the last line:
let x = f\u{61}lse; // should throw syntax error, keyword cannot contain unicode escapes
I'm closing this issue and I will open a new one to specifically track that case.