Skip to content

Remove ScriptTarget from source affecting options #1205

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 6 commits into from
Jun 17, 2025

Conversation

jakebailey
Copy link
Member

This warrants some discussion, but after #1203, the language version is actually no longer needed at all for parsing, and can be dropped from binding if we assume no ES5 support. This means we could share ASTs no matter which language version they're used with, which is pretty neat.

The only gotcha is that the scanner is still missing the regex parse error code, and the language version is needed there to give correct errors.

Honestly, I think we should do this PR to get even more AST reuse, and then go put the regex checking code elsewhere, like in the checker itself or something.

@@ -231,7 +229,7 @@ func defaultScanner() Scanner {
// Using a function rather than a global is intentional; this function is
// inlined as pure code (zeroing + moves), whereas a global requires write
// barriers since the memory is mutable.
return Scanner{languageVersion: core.ScriptTargetLatest, skipTrivia: true}
return Scanner{skipTrivia: true}
Copy link
Member Author

Choose a reason for hiding this comment

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

If I make skipTrivia a method, then flip the default, then we can also reset scanners with zeroing, which would be amazing.

@jakebailey jakebailey marked this pull request as ready for review June 17, 2025 02:34
@jakebailey jakebailey added this pull request to the merge queue Jun 17, 2025
Merged via the queue into main with commit d561370 Jun 17, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/no-script-target-source-affecting branch June 17, 2025 22:11
@jakebailey
Copy link
Member Author

The verdict was "do this, and keep removing options" plus "reintroduce regexp checking as grammar checks".

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.

2 participants