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

fix(lex): Allow JS object properties as identifiers #614

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

sjbarag
Copy link
Owner

@sjbarag sjbarag commented Jan 21, 2021

By using an identifier in a BrightScript file as an index into that object, we accidentally leaked non-Token properties on the KeyWords JS object from the lexer, e.g. return KeyWords["constructor"]. Use hasOwnProperty() to check if an identifier is a BrightScript keyword to avoid returning JavaScript internals as Tokens.

fixes #613

By using an identifier in a BrightScript file as an index into that
object, we accidentally leaked non-Token properties on the `KeyWords` JS
object from the lexer, e.g. `return KeyWords["constructor"]`.  Use
`hasOwnProperty()` to check if an identifier is a BrightScript keyword
to avoid returning JavaScript internals as Tokens.

fixes #613
@sjbarag sjbarag added bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior lexer Affects this project's lexer (aka scanner) labels Jan 21, 2021
Copy link
Collaborator

@alimnios72 alimnios72 left a comment

Choose a reason for hiding this comment

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

Nice catch

@sjbarag sjbarag merged commit 53865dd into main Jan 21, 2021
@sjbarag sjbarag deleted the allow-constructor-as-identifier-name branch January 21, 2021 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Any difference between this BrightScript implementation and RBI, or otherwise unexpected behavior lexer Affects this project's lexer (aka scanner)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

constructor identifier causes parse issues in brs
2 participants