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

Parser Idempotency issue: braces added every time after each pass #3133

Closed
MahnurA opened this issue Jul 11, 2023 · 5 comments · Fixed by #3172
Closed

Parser Idempotency issue: braces added every time after each pass #3133

MahnurA opened this issue Jul 11, 2023 · 5 comments · Fixed by #3172
Assignees
Labels
bug Something isn't working

Comments

@MahnurA
Copy link

MahnurA commented Jul 11, 2023

Describe the bug
Starting and ending braces are added within an empty code block.

To Reproduce

This javascript

with (this) {{
}}

is transformed to the following, after passing through the parser:

with (this) {{
    {
    }
}}

And then to below, after another pass through:

with (this) {{
    {
        {
        }
    }
}}

Expected behavior
Multiple runs through the parser should result in the same output.

Build environment (please complete the following information):

  • OS: Ubuntu
  • Version: 20.04
  • Target triple: x86_64-unknown-linux-gnu
  • Rustc version: rustc 1.70.0

Additional context
Found by #4822

@MahnurA MahnurA added the bug Something isn't working label Jul 11, 2023
@MahnurA MahnurA changed the title Idempotency issue: braces added every time after passing through the formatter and linter Parser Idempotency issue: braces added every time after each pass Jul 12, 2023
@veera-sivarajan
Copy link
Contributor

Hi, I'd like to work on this.

@jedel1043
Copy link
Member

@veera-sivarajan Assigned!

@jedel1043 jedel1043 moved this to In Progress in Boa pre-v1 Jul 15, 2023
@veera-sivarajan
Copy link
Contributor

@MahnurA Can you please let me know the command that shows the transformed code? I tried cargo run -- test.js --dump-ast json-pretty with the given input but did not see any difference in the output.

@MahnurA
Copy link
Author

MahnurA commented Jul 15, 2023

@veera-sivarajan I used the fuzzer to discover the bug, specifically the parser-idempotency fuzzer. However after #3059 was merged the fuzzers can't run anymore (not sure what broke but will be fixed soon), but you should still be able to run the previous version and see.

veera-sivarajan added a commit to veera-sivarajan/boa that referenced this issue Jul 25, 2023
This PR fixes boa-dev#3133 by correctly implementing `ToIndentedString`
for `with` statement.

It also replaces the existing `ToInternedString` implementation
because it is implemented for all types implementing
`ToIndentedString` in `boa_interner/src/lib.rs`.
@addisoncrump
Copy link
Contributor

I can confirm that this is still present.

raskad pushed a commit to veera-sivarajan/boa that referenced this issue Dec 3, 2023
This PR fixes boa-dev#3133 by correctly implementing `ToIndentedString`
for `with` statement.

It also replaces the existing `ToInternedString` implementation
because it is implemented for all types implementing
`ToIndentedString` in `boa_interner/src/lib.rs`.
github-merge-queue bot pushed a commit that referenced this issue Dec 4, 2023
* Fix a Parser Idempotency Issue

This PR fixes #3133 by correctly implementing `ToIndentedString`
for `with` statement.

It also replaces the existing `ToInternedString` implementation
because it is implemented for all types implementing
`ToIndentedString` in `boa_interner/src/lib.rs`.

* Add test for with statement formatting

---------

Co-authored-by: raskad <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in Boa pre-v1 Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants