-
-
Notifications
You must be signed in to change notification settings - Fork 818
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
Added reserved keywords #1741
Added reserved keywords #1741
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1741 +/- ##
==========================================
+ Coverage 87.3% 87.32% +0.02%
==========================================
Files 48 48
Lines 5709 5720 +11
Branches 1512 1512
==========================================
+ Hits 4984 4995 +11
Misses 448 448
Partials 277 277
Continue to review full report at Codecov.
|
@charles-cooper 👍 (and unit tests pass) => can merge |
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.
can you add a test to validate that #1710 has been fixed? and then I think this is good to go
@charles-cooper went to go add tests, but ran into a ton of issues. And then I got into a refactoring rut, so #1746 came out. TL;DR is that we use inconsistent methods for representing constants |
5d35c71
to
eeac89b
Compare
Found a bunch of uncaught |
yay for code quality :) |
01bd2af
to
5a9460d
Compare
A bunch of force pushing for linting issues lol |
Conversion from error using ast.parse() | ||
""" | ||
def __init__(self, syntax_error: SyntaxError, source_code: str): | ||
item = types.SimpleNamespace() # TODO: Create an actual object for this |
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.
TODO is here in case this object is more broadly useful (which I don't think it is)
Would also just be better if it were a static object
try: | ||
py_ast = python_ast.parse(reformatted_code) | ||
except SyntaxError as e: | ||
# TODO: Ensure 1-to-1 match of source_code:reformatted_code SyntaxErrors |
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.
TODO is here because theorhetically there is a scenario where this code reformatting could affect the location of offsets used to display an error. Would be best if the conversion was accounted for.
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.
This is interesting because syntax error reporting actually happens on the reformatted code, but other error reporting can happen on the untransformed code. Look at for instance how the struct -> class
preparsing rule affects error reporting:
# syntax error
$ vyper -f ir /dev/stdin <<EOF
struct Foo: aoijewofijwef098 \`\`
EOF
File "<unknown>", line 1
class Foo: aoijewofijwef098 ``
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
vyper.exceptions.PythonSyntaxException: line 1:29 SyntaxError: invalid syntax
---> 1 struct Foo: aoijewofijwef098 ``
------------------------------------^
# vs plain structure exception
$ vyper -f ir /dev/stdin <<EOF
struct Foo: aoijewofijwef098
EOF
Error compiling: /dev/stdin
vyper.exceptions.StructureException: line 1:11 Structs can only contain variables
---> 1 struct Foo: aoijewofijwef098
------------------^
2
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.
Does this add buggy behavior now?
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.
no, the behavior is as buggy as before
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.
... Ship it!
- Changed filename to be more correct - Added built-in functions and reserved keywords to tests - Removed redundant testing
Note: Sort in pytest decorator instead
Note: RLPList in built-in functions was mixed case and caused an error
Co-Authored-By: Charles Cooper <cooper.charles.m@gmail.com>
146c4f6
to
c5160de
Compare
Co-Authored-By: Charles Cooper <cooper.charles.m@gmail.com>
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.
I'm pretty happy with this. Thanks!
What I did
Added some more things to the internal reserved keyword list
Fixes: #1710
How I did it
grep-foo
How to verify it
Added all reserved keywords to test. Added test for function names.
Description for the changelog
N/A
Cute Animal Picture