Skip to content

Conversation

arnog
Copy link

@arnog arnog commented Sep 22, 2023

…global are confused for a global

Don't exclude a built-in global (e.g. eval) followed by an identifier , but exclude built-in global followed by an open paren (i.e. eval()

See #3870 for an example.

…a built-in global are confused for a global

Don't exclude a built-in global (e.g. `eval`) followed by an identifier , but exclude built-in global followed by  an open paren (i.e. `eval(`)

See highlightjs#3870 for an example.
/\b/,
noneOf([
...ECMAScript.BUILT_IN_GLOBALS,
...ECMAScript.BUILT_IN_GLOBALS.map((x) => x + '\\('),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need this same protection for super and import also? And wouldn't just adding a \b on the other side of noneOf get the job done here without explicitly looking for a (?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, there might be more bugs in the way the parser handles keywords and other keywords affected. I haven't tested that and I'm not sure of what the logic behind the original code was, but your suggestion seems reasonable.

Same thing for using \b instead of (, again I'm not sure of what the original logic was so I tried to find a minimal solution that would fix the test case I encountered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to review again after you update.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That PR was just a suggestion. I'll let someone with a better understanding of the codebase to contribute a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants