Skip to content

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

Merged
merged 7 commits into from
Feb 26, 2019
Merged

fix invalid break continue return yield #542

merged 7 commits into from
Feb 26, 2019

Conversation

Rustinante
Copy link
Contributor

@codecov-io
Copy link

codecov-io commented Feb 25, 2019

Codecov Report

Merging #542 into master will decrease coverage by 0.12%.
The diff coverage is 46.66%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
vm/src/error.rs 0% <0%> (ø) ⬆️
vm/src/compile.rs 45.65% <58.33%> (-0.52%) ⬇️
vm/src/stdlib/string.rs 22.95% <0%> (-4.79%) ⬇️
wasm/lib/src/browser_module.rs 0% <0%> (ø) ⬆️
parser/src/error.rs 14.28% <0%> (ø) ⬆️
vm/src/frame.rs 46.44% <0%> (ø) ⬆️
vm/src/obj/objtype.rs 60.69% <0%> (ø) ⬆️
src/main.rs 14.81% <0%> (+0.09%) ⬆️
parser/src/fstring.rs 76.27% <0%> (+0.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 027a684...fee6a47. Read the comment docs.

@@ -16,7 +16,7 @@ struct Compiler {
nxt_label: usize,
source_path: Option<String>,
current_source_location: ast::Location,
in_loop: bool,
loop_depth: usize,
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@@ -252,6 +253,7 @@ impl CodeObject {
source_path: String,
first_line_number: usize,
obj_name: String,
is_function_obj: bool,
Copy link
Contributor

@OddCoincidence OddCoincidence Feb 25, 2019

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

@Rustinante Rustinante Feb 25, 2019

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@Rustinante Rustinante Feb 26, 2019

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.

@OddCoincidence OddCoincidence merged commit 587f871 into RustPython:master Feb 26, 2019
@OddCoincidence
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants