-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix invalid break continue return yield #542
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 invalid break continue return yield #542
Conversation
Codecov Report
@@ Coverage Diff @@
## master #542 +/- ##
==========================================
- Coverage 44.72% 44.59% -0.13%
==========================================
Files 72 72
Lines 15536 15574 +38
Branches 3964 3977 +13
==========================================
- Hits 6948 6946 -2
- Misses 6676 6720 +44
+ Partials 1912 1908 -4
Continue to review full report at Codecov.
|
vm/src/compile.rs
Outdated
@@ -16,7 +16,7 @@ struct Compiler { | |||
nxt_label: usize, | |||
source_path: Option<String>, | |||
current_source_location: ast::Location, | |||
in_loop: bool, | |||
loop_depth: usize, |
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.
Did you see my comment here? The in_loop
flag should suffice.
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.
Changed.
vm/src/bytecode.rs
Outdated
@@ -252,6 +253,7 @@ impl CodeObject { | |||
source_path: String, | |||
first_line_number: usize, | |||
obj_name: String, | |||
is_function_obj: bool, |
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.
Why add this here instead of another flag in Compiler
like in_loop
?
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.
Both ways would work. I think this has the advantage that we don't have to remember to save and restore the flag when exiting the block. It's also how it's done in the cpython implementation.
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.
Both ways would work. I think this has the advantage that we don't have to remember to save and restore the flag when exiting the block.
True but it has the disadvantage that it makes the information accessible in a wider scope than is currently necessary. So unless there is some feature that depends on distinguish code objects that are functions, I'd prefer just to use a flag for now.
It's also how it's done in the cpython implementation.
Could you link to the relevant cpython bits?
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.
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.
@OddCoincidence I've changed to using boolean flags for checking the invalid return and yield.
Thanks! |
#497