Skip to content

Update test262 suite to latest and fix using/await using issues#31

Merged
adams85 merged 8 commits intoadams85:masterfrom
lahma:parser-fixes
Mar 28, 2026
Merged

Update test262 suite to latest and fix using/await using issues#31
adams85 merged 8 commits intoadams85:masterfrom
lahma:parser-fixes

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 24, 2026

Summary

  • Fix IsUsingKeyword to correctly handle of as a variable name in for-loops with using/await using declarations
  • Add opt-in AllowCallExpressionAsLhs parser option for AnnexB B.3.9 (Runtime Errors for Function Call Assignment Targets)
  • Update test262 suite SHA and allow-list

IsUsingKeyword fix

The isFor && id is "of" check was too aggressive — it rejected of as a binding name without looking ahead. Now disambiguates:

Syntax Interpretation
for (using of = null;;) Regular for-loop, of is variable name
for (using of of []) For-of loop, of is binding name
for (await using of of []) Await-using, of is binding name
for (using of <expr>) Not a using keyword, using is expression

AllowCallExpressionAsLhs

Per AnnexB B.3.7, in non-strict mode f() = g() should parse successfully and throw ReferenceError at runtime (not SyntaxError at parse time). The new option (defaults to false) allows CallExpression as LHS in:

  • Simple and compound assignments
  • Prefix/postfix update expressions
  • For-in/for-of loop left-hand side

Test plan

  • All edge cases verified (using of =, using of of, await using of of, using as expression)
  • Acornima unit tests pass (10908/10909, 1 pre-existing net10.0 failure in CanHandleDeepRecursion on Windows fixed by adjusting limits)
  • test262 suite: all tests now pass, 0 regressions

🤖 Generated with Claude Code

UPDATE

The IsUsingKeyword fix has been corrected as it didn't handle some edge cases (e.g. for (using of == null;;) or for (using ofx of []), etc.)

The AnnexB B.3.9 stuff has been extracted to a separate PR (#33).

lahma and others added 3 commits March 24, 2026 08:45
…AsLhs option

Fix IsUsingKeyword to correctly handle 'of' as a variable name in for-loops:
- `for (using of = null;;)` - regular for-loop with variable named 'of'
- `for (using of of [])` - for-of loop with binding named 'of'
- `for (await using of of [])` - await-using with binding named 'of'

Add opt-in AllowCallExpressionAsLhs parser option for AnnexB B.3.7 support:
- When enabled in non-strict mode, CallExpression is allowed as LHS in
  assignments, compound assignments, update expressions, and for-in/of loops
- The runtime should throw ReferenceError instead of parser throwing SyntaxError

Update test262 suite SHA and allow-list.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…exts

Per the explicit-resource-management spec:
- using/await using declarations in for-in loops are invalid syntax
- using/await using declarations are not allowed as the sole statement
  in if/while/do/for bodies or labeled statements (non-block contexts)

This fixes 18 test262 test cases (9 files x 2 modes).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… assignments

- Enable AllowCallExpressionAsLhs in both Program.cs and Test262Test.cs runners
- Distinguish logical assignments (&&=, ||=, ??=) from regular/compound assignments:
  AnnexB B.3.7 only applies to =, +=, etc., not logical assignments which require
  'simple' assignment target per spec
- Add LogicalAssignment to LeftHandSideKind enum
- Remove 7 callexpression entries from allow-list (all now pass)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lahma lahma changed the title Fix using/await-using 'of' disambiguation and add AllowCallExpressionAsLhs Update test262 suite to latest and fix issues Mar 24, 2026
The previous value of 855 overflowed when running in the full test suite on
net10.0 (stack partially consumed by preceding tests). 845 is near the limit
while leaving enough margin for the full suite context.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lahma lahma marked this pull request as ready for review March 24, 2026 07:33
@adams85
Copy link
Copy Markdown
Owner

adams85 commented Mar 24, 2026

Thank you for submitting these corrections. I'll need some time to review them thoroughly, but I have some preliminary remarks:

  • The current implementation of (await) using declarations in for loops looks buggy indeed. AFAICS, these problems are also present in the upstream project.

  • However, I have some concerns about the "Runtime Errors for Function Call Assignment Targets" stuff:

    On one hand, acorn directly supports Annex B.3 features in non-strict mode, without putting those behind some kind of feature flag. To follow this convention, we probably shouldn't introduce the AllowCallExpressionAsLhs switch.

    On the other hand, this feature looks like a recent addition, which is only present in the draft of ES2026. At least, I couldn't find this in the spec of earlier versions. And, as you're surely aware Acornima is ES2023-compliant at the moment. (BTW, the reference is wrong, it's B.3.9, not B.3.7).

    So I'm a bit puzzled as to what to do with this. Not even the upstream project has implemented this yet. Maybe we'd better wait for that.

@lahma
Copy link
Copy Markdown
Collaborator Author

lahma commented Mar 24, 2026

Thank you for the feedback these were issues that were somewhat blocking Jint's test suite, but not a pressing concern or anything. Feel free to adjust and throw away things (or create a separate change set that you feel comfortable with).

@adams85 adams85 changed the title Update test262 suite to latest and fix issues Update test262 suite to latest and fix using/await using issues Mar 27, 2026
@adams85
Copy link
Copy Markdown
Owner

adams85 commented Mar 27, 2026

FYI, I made some corrections to the using/await using fix (see the updated PR description) and merged #32 into this PR. I plan to merge and release it soon.

I also extracted the AnnexB B.3.9 stuff into a separate a PR, which I'm going to leave as a draft for now, until I make up my mind what to do with it.

Is this okay with you?

@lahma
Copy link
Copy Markdown
Collaborator Author

lahma commented Mar 27, 2026

Is this okay with you?

I'm happy if I'm of any help, even with the AI tooling. Feel free to do whatever you feel is best, it's your codebase, I'm not looking for attribution either. This pushes Jint forward so that's just my selfish goal 👍

@adams85
Copy link
Copy Markdown
Owner

adams85 commented Mar 28, 2026

These bugfixes are tremendously useful, keep 'em coming! 👍

In general, draft/experimental features are welcome too, but those may be put on hold as I want to keep the project as close to upstream as possible to avoid extra work and ensure maintainability in the long run.

So, in the case of features, it's best to have a discussion beforehand to find out whether the time is ripe.

@adams85 adams85 merged commit aed319d into adams85:master Mar 28, 2026
3 checks passed
@lahma lahma deleted the parser-fixes branch March 28, 2026 20:00
@adams85
Copy link
Copy Markdown
Owner

adams85 commented Apr 1, 2026

@lahma FYI, I backported the using and Annex B.3.9 fixes to acornjs. The latter hasn't been accepted yet (might never be), however I decided to release this pack anyway so you can move forward with Jint.

@lahma
Copy link
Copy Markdown
Collaborator Author

lahma commented Apr 3, 2026

Thank you for the update, Jint has integrated the version ( sebastienros/jint#2374 ) and again we got rid of more exclusions 🥳

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