Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserved word (keyword) as identifier and object properties #1117

Closed
jevancc opened this issue Feb 5, 2021 · 4 comments
Closed

Reserved word (keyword) as identifier and object properties #1117

jevancc opened this issue Feb 5, 2021 · 4 comments
Labels
bug Something isn't working parser Issues surrounding the parser
Milestone

Comments

@jevancc
Copy link
Contributor

jevancc commented Feb 5, 2021

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

@jevancc jevancc added the bug Something isn't working label Feb 5, 2021
@jevancc
Copy link
Contributor Author

jevancc commented Feb 5, 2021

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.

@Razican
Copy link
Member

Razican commented Jan 31, 2022

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?

@lupd
Copy link
Contributor

lupd commented Apr 9, 2022

The first example still throws a syntax error. The second throws no errors. The third example incorrectly errors for the first two lines.

@Razican
Copy link
Member

Razican commented Mar 31, 2023

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.

@Razican Razican closed this as completed Mar 31, 2023
@jedel1043 jedel1043 added this to the v0.17.0 milestone May 30, 2023
@jedel1043 jedel1043 added the parser Issues surrounding the parser label May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Issues surrounding the parser
Projects
None yet
Development

No branches or pull requests

4 participants