Skip to content

fix(parser): comprehensive arrow function validation (25 tests)#187

Merged
ohah merged 1 commit intomainfrom
feature/arrow-function-validation
Mar 20, 2026
Merged

fix(parser): comprehensive arrow function validation (25 tests)#187
ohah merged 1 commit intomainfrom
feature/arrow-function-validation

Conversation

@ohah
Copy link
Copy Markdown
Owner

@ohah ohah commented Mar 20, 2026

Summary

  • arrow-function 100% (343/343), async-arrow 98.3% (59/60)
  • rest params in parens, ASI restriction, super 상속
  • non-simple params + strict body, eval/arguments 검증
  • duplicate params in destructuring, yield/await in defaults
  • invalid arrow param form (call expr 거부)

Test plan

  • zig build test 통과
  • zig fmt --check src/ 통과
  • Test262 arrow-function 25건 개선 확인

🤖 Generated with Claude Code

Add comprehensive arrow function validation to fix 25+ Test262 failures:

- Super access: arrow functions now inherit allow_super_call and
  allow_super_property from enclosing method/constructor context
- ASI restriction: enforce [no LineTerminator here] before => in the
  cover grammar path (after parseConditionalExpression)
- Rest parameters: support ...rest in parenthesized expressions via
  parseExpressionOrRest for arrow function cover grammar
- Non-simple params: detect destructuring/default/rest params and set
  has_simple_params=false so "use strict" body triggers SyntaxError
- eval/arguments: check strict mode binding for single-identifier
  arrow params (both sync and async)
- Duplicate params: add collectCoverParamNames that walks into
  destructuring patterns (object/array) to detect duplicates
- Yield in params: detect yield expressions in arrow param defaults
  via checkCoverParamDefaultForYieldAwait
- Await in async params: detect await identifiers in async arrow
  params via checkAsyncArrowParamsForAwait
- Rest validation: check rest-init and trailing comma in cover grammar
- Arrow param form: reject call_expression as arrow params via
  isValidArrowParamForm (fixes escaped-async and lineterminator)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ohah ohah added the enhancement New feature or request label Mar 20, 2026
@ohah ohah self-assigned this Mar 20, 2026
@ohah ohah merged commit 5744bd6 into main Mar 20, 2026
9 checks passed
ohah added a commit that referenced this pull request Mar 20, 2026
Re-apply PR #186 changes that conflicted with the already-merged PR #187:

1. checkIdentifierEscapedKeyword: skip kw_await/kw_yield (context-dependent)
2. Function declaration name parsed before enterFunctionContext (outer context)
3. Retroactive strict mode checks (checkStrictFunctionName, checkStrictParamNames)
4. BigInt property keys in parsePropertyKey
5. Yield expression terminators: add template_middle/template_tail
6. Object shorthand validation: non-identifier keys error
7. CoverInitializedName tracking in parseExpressionStatement
8. in_formal_parameters flag for yield/await expression checks
9. checkObjectDuplicateProto: skip shorthand properties

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ohah added a commit that referenced this pull request Mar 20, 2026
Re-apply PR #186 changes that conflicted with the already-merged PR #187:

1. checkIdentifierEscapedKeyword: skip kw_await/kw_yield (context-dependent)
2. Function declaration name parsed before enterFunctionContext (outer context)
3. Retroactive strict mode checks (checkStrictFunctionName, checkStrictParamNames)
4. BigInt property keys in parsePropertyKey
5. Yield expression terminators: add template_middle/template_tail
6. Object shorthand validation: non-identifier keys error
7. CoverInitializedName tracking in parseExpressionStatement
8. in_formal_parameters flag for yield/await expression checks
9. checkObjectDuplicateProto: skip shorthand properties

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant