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

[Merged by Bors] - Fix labelled block statement #2285

Closed

Conversation

creampnx-x
Copy link
Contributor

This Pull Request fixes x-after-break-to-label

Example

{
  let x = 2;
  L: {
    let x = 3;
    console.log(x === 3);
    break L;
    console.log(false);
  }
  console.log(x === 2);
}

Previously

Uncaught "SyntaxError": "Cannot use the undeclared label 'L'"

Now

true
true

What did I do

  1. add lable to Node::Block
  2. push labelled-block's control info to jump_info list
  3. pop it before Opcode::PopEnvironment

@codecov
Copy link

codecov bot commented Sep 16, 2022

Codecov Report

Merging #2285 (eafb351) into main (24f4155) will decrease coverage by 0.12%.
The diff coverage is 37.93%.

@@            Coverage Diff             @@
##             main    #2285      +/-   ##
==========================================
- Coverage   41.68%   41.56%   -0.13%     
==========================================
  Files         234      235       +1     
  Lines       22001    22120     +119     
==========================================
+ Hits         9172     9194      +22     
- Misses      12829    12926      +97     
Impacted Files Coverage Δ
...ne/src/syntax/parser/statement/labelled_stm/mod.rs 37.50% <ø> (ø)
boa_engine/src/syntax/ast/node/block/mod.rs 43.75% <25.00%> (-6.25%) ⬇️
boa_engine/src/bytecompiler/mod.rs 29.28% <40.00%> (+0.08%) ⬆️
boa_engine/src/builtins/set/ordered_set.rs 7.40% <0.00%> (-7.41%) ⬇️
boa_engine/src/syntax/lexer/template.rs 36.95% <0.00%> (-2.63%) ⬇️
boa_engine/src/builtins/iterable/mod.rs 48.85% <0.00%> (-0.76%) ⬇️
boa_engine/src/object/mod.rs 20.17% <0.00%> (-0.40%) ⬇️
boa_engine/src/vm/mod.rs 46.90% <0.00%> (-0.21%) ⬇️
boa_engine/src/builtins/array_buffer/mod.rs 9.62% <0.00%> (-0.15%) ⬇️
...ine/src/syntax/parser/expression/assignment/mod.rs 52.42% <0.00%> (-0.05%) ⬇️
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Razican Razican added bug Something isn't working parser Issues surrounding the parser run-benchmark Label used to run banchmarks on PRs labels Sep 16, 2022
@Razican Razican added this to the v0.17.0 milestone Sep 16, 2022
@jedel1043
Copy link
Member

Test262 conformance changes

VM implementation

Test result main count PR count difference
Total 91,827 91,827 0
Passed 64,942 64,954 +12
Ignored 16,672 16,672 0
Failed 10,213 10,201 -12
Panics 0 0 0
Conformance 70.72% 70.74% +0.01%
Fixed tests (12):
test/language/block-scope/leave/x-after-break-to-label.js [strict mode] (previously Failed)
test/language/block-scope/leave/x-after-break-to-label.js (previously Failed)
test/language/block-scope/leave/nested-block-let-declaration-only-shadows-outer-parameter-value-2.js [strict mode] (previously Failed)
test/language/block-scope/leave/nested-block-let-declaration-only-shadows-outer-parameter-value-2.js (previously Failed)
test/language/block-scope/leave/verify-context-in-labelled-block.js [strict mode] (previously Failed)
test/language/block-scope/leave/verify-context-in-labelled-block.js (previously Failed)
test/language/block-scope/leave/nested-block-let-declaration-only-shadows-outer-parameter-value-1.js [strict mode] (previously Failed)
test/language/block-scope/leave/nested-block-let-declaration-only-shadows-outer-parameter-value-1.js (previously Failed)
test/language/statements/do-while/S12.6.1_A4_T5.js [strict mode] (previously Failed)
test/language/statements/do-while/S12.6.1_A4_T5.js (previously Failed)
test/language/statements/while/S12.6.2_A4_T5.js [strict mode] (previously Failed)
test/language/statements/while/S12.6.2_A4_T5.js (previously Failed)

Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Thank you! I have some nitpicks, but the implementation looks good!

boa_engine/src/syntax/ast/node/block/mod.rs Outdated Show resolved Hide resolved
boa_engine/src/syntax/ast/node/block/mod.rs Outdated Show resolved Hide resolved
boa_engine/src/bytecompiler/mod.rs Outdated Show resolved Hide resolved
@jedel1043 jedel1043 linked an issue Sep 16, 2022 that may be closed by this pull request
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for the addition!

@raskad raskad modified the milestones: v0.17.0, v0.16.0 Sep 18, 2022
@raskad
Copy link
Member

raskad commented Sep 18, 2022

bors r+

bors bot pushed a commit that referenced this pull request Sep 18, 2022
<!---
Thank you for contributing to Boa! Please fill out the template below, and remove or add any
information as you feel neccesary.
--->

This Pull Request fixes [x-after-break-to-label](https://github.com/tc39/test262/blob/dc1dc28aa46d9457e47550b34e6f25a8b80de826/test/language/block-scope/leave/x-after-break-to-label.js)

### Example
```js
{
  let x = 2;
  L: {
    let x = 3;
    console.log(x === 3);
    break L;
    console.log(false);
  }
  console.log(x === 2);
}
```

### Previously
> Uncaught "SyntaxError": "Cannot use the undeclared label 'L'"

### Now
> true <br> true

### What did I do
1. add `lable` to `Node::Block`
2. push labelled-block's `control info` to `jump_info` list
3. pop it before `Opcode::PopEnvironment`

Co-authored-by: creampnx_x <2270436024@qq.com>
@bors
Copy link

bors bot commented Sep 18, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fix labelled block statement [Merged by Bors] - Fix labelled block statement Sep 18, 2022
@bors bors bot closed this Sep 18, 2022
@jedel1043 jedel1043 linked an issue Oct 17, 2022 that may be closed by this pull request
@jedel1043 jedel1043 removed a link to an issue Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Issues surrounding the parser run-benchmark Label used to run banchmarks on PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

labeled block support
4 participants