Move reserved keywords check into the type checker#2286
Merged
iamdefinitelyahuman merged 4 commits intoJan 28, 2021
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2286 +/- ##
==========================================
+ Coverage 85.45% 85.47% +0.01%
==========================================
Files 84 84
Lines 8583 8580 -3
Branches 2076 2079 +3
==========================================
- Hits 7335 7334 -1
+ Misses 747 746 -1
+ Partials 501 500 -1
Continue to review full report at Codecov.
|
fubuloubu
approved these changes
Jan 28, 2021
|
|
||
|
|
||
| # Cannot be used for variable or member naming | ||
| RESERVED_KEYWORDS = { |
Contributor
There was a problem hiding this comment.
it would be lovely if we can somehow pull this from our stuff dyanmically, instead of statically maintaining this alongside changes to the compiler
Contributor
Author
There was a problem hiding this comment.
Definitely worth implementing.
43d8305 to
eec0427
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What I did
Move reserved keyword checks into the type checker.
How I did it
The logic was already partially being handled within type checking: shadowing of builtins and environment variables would raise upon attempted assignment. However, reserved keywords and opcodes weren't caught until later when generating the
GlobalContextobject.I've moved the reserved keywords list into
namespaceand am now applying the check on all new assignments as they're added to theNamespaceobject. For object members (values in events, structs, interfaces) I added avalidate_identifiermethod that's slightly looser: it doesn't raise on collisions between non-builtins, so that e.gMyStruct.fooandself.foowon't collide.How to verify it
Run the tests. I had to modify a few tests in order to make this work, because the exception being raised in some places has changed.
Cute Animal Picture