-
-
Notifications
You must be signed in to change notification settings - Fork 793
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
Move reserved keywords check into the type checker #2286
Move reserved keywords check into the type checker #2286
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.
|
|
||
|
||
# Cannot be used for variable or member naming | ||
RESERVED_KEYWORDS = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be lovely if we can somehow pull this from our stuff dyanmically, instead of statically maintaining this alongside changes to the compiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely worth implementing.
43d8305
to
eec0427
Compare
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
GlobalContext
object.I've moved the reserved keywords list into
namespace
and am now applying the check on all new assignments as they're added to theNamespace
object. For object members (values in events, structs, interfaces) I added avalidate_identifier
method that's slightly looser: it doesn't raise on collisions between non-builtins, so that e.gMyStruct.foo
andself.foo
won'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