Skip to content
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

Labeled if statement #2295

Closed
SheetJSDev opened this issue Sep 20, 2022 · 2 comments
Closed

Labeled if statement #2295

SheetJSDev opened this issue Sep 20, 2022 · 2 comments
Labels
enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine.
Milestone

Comments

@SheetJSDev
Copy link

A slight twist on #2243 :

/* this works in commit 5d9b405 */
foo: {
  console.log('face');
  break foo;
  console.log('this will not be executed');
}
/* This elicits `Uncaught "SyntaxError": "Cannot use the undeclared label 'bar'"` */
bar: if(true){
  console.log('face');
  break bar;
  console.log('this will not be executed');
}
console.log('swap');
@SheetJSDev SheetJSDev added the bug Something isn't working label Sep 20, 2022
@jedel1043 jedel1043 added this to the v0.17.0 milestone Sep 21, 2022
@jedel1043 jedel1043 added parser Issues surrounding the parser vm Issues and PRs related to the Boa Virtual Machine. labels Sep 21, 2022
@Razican
Copy link
Member

Razican commented Sep 21, 2022

Ideally, all these should be treated as LabeledStatement in general. This would be easier to implement once #1371 is implemented.

@jedel1043 jedel1043 linked a pull request Oct 17, 2022 that will close this issue
bors bot pushed a commit that referenced this issue Oct 22, 2022
This Pull Request changes the following:

- Implements the `LabelledStatement` Parse node.
- Removes `label` from all label-able items (switch, blocks and loop statements).
- Adjusts parsing to the new AST.

#2295 isn't fixed by this, but with this change it should be easier to fix.
@jedel1043 jedel1043 added enhancement New feature or request and removed bug Something isn't working parser Issues surrounding the parser labels Nov 8, 2022
@jedel1043 jedel1043 moved this to To do in Boa pre-v1 Nov 8, 2022
@nekevss nekevss moved this from To do to Done in Boa pre-v1 Jan 16, 2023
@nekevss nekevss moved this from Done to To do in Boa pre-v1 Jan 16, 2023
bors bot pushed a commit that referenced this issue Jan 19, 2023
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel necessary.
--->

This Pull Request addresses #2295, and another case that I came across when I was adding `Break` to the `ByteCompiler`

I did have a question that came up during this regarding the spec. We currently don't implement the [BreakableStatement](https://tc39.es/ecma262/#prod-BreakableStatement). Any thoughts on whether we should be? Especially since `BreakableStatement` seems to be a bit of a inaccurate since `LabelledStatement` is breakable too.

It changes the following:

- Moves handling of label jump out of `compile_block` and into `compile_labelled`.
- Adds a couple more tests to keep track of `LabelledStatement` breaks.


Co-authored-by: Ness <[email protected]>
@SheetJSDev
Copy link
Author

Commit 90d310b (thanks @nekevss !) fixed this example and added a representative test case.

@github-project-automation github-project-automation bot moved this from To do to Done in Boa pre-v1 Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine.
Projects
Status: Done
Development

No branches or pull requests

3 participants