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

Move syntax errors from the compiler to the parser #1907

Closed
raskad opened this issue Mar 7, 2022 · 2 comments
Closed

Move syntax errors from the compiler to the parser #1907

raskad opened this issue Mar 7, 2022 · 2 comments
Labels
Internal Category for changelog parser Issues surrounding the parser
Milestone

Comments

@raskad
Copy link
Member

raskad commented Mar 7, 2022

Currently we have some syntax errors that are being thrown in the compiler. They should be already be thrown in the parser.

The best case to search for them is to look for throw_syntax_error and construct_syntax_error in boa_engine/src/bytecompiler.rs. There may be state that must be added during the parsing for all of the errors to be moved to the parsing phase.

After this is fixed, Context::compile should not need to return a Result anymore.

@raskad raskad added parser Issues surrounding the parser Internal Category for changelog labels Mar 7, 2022
@raskad raskad added this to the v0.15.0 milestone Mar 7, 2022
bors bot pushed a commit that referenced this issue Apr 27, 2022
This Pull Request changes the following:

- Implement redeclaration errors in the parser
- Remove redeclaration errors from the compiler (this is a big step towards #1907)
- Fix some failing tests on the way

This requires a slight change in our public api. The Parser new requires a full `Context` instead of just the `Interner` for parsing new code. This is required, because if multiple scripts are parsed (e.g. every input in the REPL) global variables must be checked for redeclarations.
@Razican
Copy link
Member

Razican commented Jun 1, 2022

After #2027, what's missing here?

@Razican Razican modified the milestones: v0.15.0, v0.16.0 Jun 1, 2022
@raskad
Copy link
Member Author

raskad commented Jun 2, 2022

There are still some syntax errors in the bytecompiler left:

  • Check for undeclared labels at parse time to avoid this
  • Check if continue statements occur within a loop to avoid this
  • Check if break statements occur within loop or switch to avoid this
  • Check for invalid left-had-side in assignments (all others)

Razican pushed a commit that referenced this issue Jun 8, 2022
This Pull Request changes the following:

- Implement redeclaration errors in the parser
- Remove redeclaration errors from the compiler (this is a big step towards #1907)
- Fix some failing tests on the way

This requires a slight change in our public api. The Parser new requires a full `Context` instead of just the `Interner` for parsing new code. This is required, because if multiple scripts are parsed (e.g. every input in the REPL) global variables must be checked for redeclarations.
@Razican Razican modified the milestones: v0.16.0, v0.17.0 Sep 19, 2022
bors bot pushed a commit that referenced this issue Feb 1, 2023
This Pull Request changes the following:

- Move postfix/prefix increment and decrement operations from the `Unary` expression to a new `Update` expression.
- Add a special type for the `Update` expression target as it is very limited in comparision to an `Unary` target.
- This makes bytecode compilation more typesafe for these operations and removes syntax errors from the bytecompiler without introducing panics (see #1907).
@bors bors bot closed this as completed in 310c671 Feb 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Category for changelog parser Issues surrounding the parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants