Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The compiler prefixes conflicting ident names with
$$
to prevent the output from containing a SyntaxError or unintentionally declarying conflicting names.However, some of the managed keywords are outdated (keywords listed on the Future reserved words in older standards section), some are not actually keywords, and the list of Chrome global variables is far too extensive.
Changes
Hashtbl
instead of binary search (keywords are small enough)Future works
If a name is not an actual JS keyword, there should be no problem defining the identifier with the name inside the module scope, even if it is used in the
globalThis
scope. But theSyntaxError
only occurs in the CommonJS system.IMHO we need a way to allow using those names if users want. In a previous PR I proposed a syntax using exotic ident.
However, this cannot be implemented in the current parser. If necessary, the scanner would have to be modified to keep exotic tokens, which would significantly increase the complexity of printers.