ReviewOS

zig-utils/zig-js

Errors: render class field, class name, and super SyntaxErrors

#960
Closed chris opened this 9 days ago ·
9 days ago

Parent: #899

Problem

Five direct bare exits in parseSuper, parsePropertyName, and parseClassExpr discard the offending token or grammar context.

Executed on current main (372a9a4), six eval probes expose eval: UnexpectedToken at .... Raw JavaScriptCore 625.1.22 reports:

  • an invalid super. member as an unexpected exact token followed by Expected a property name after '.'.
  • bare super as super is not valid in this context.
  • a forbidden class binding as Cannot use 'let' as a class name in strict mode.
  • an unterminated class field as an unexpected exact token followed by Expected a ';' following a class field.
  • an invalid class property token as the exact generic unexpected token

Implementation

  • Reuse the property-after-dot reason for super..
  • Attach bare super to its keyword without a token prefix.
  • Retain the class binding and format its strict-name diagnostic.
  • Retain invalid property and class-field follower tokens.
  • Add no allocation or source scan to successful class parsing.

Decorator proposal paths are intentionally outside this issue because JavaScriptCore 625.1.22 and Node 24.18 do not provide a compatible grammar/message oracle for the syntax zig-js accepts.

Verification

  • Pin reason, message, and byte offset for all six probes.
  • Add a focused production eval case for each message/token family.
  • Compare exact-parent class, class-fields, and super-property test262 subtrees with nonzero denominators and report flips.
9 days ago

Implemented and pushed to main in 14b4273.

  • Invalid super. members reuse the exact property-name diagnostic; bare super retains its keyword context.
  • Strict class bindings retain their spelling, and invalid class property/field followers retain their exact tokens.
  • Successful class parsing adds no allocation or source scan.
  • Decorator proposal diagnostics remain separately scoped because neither available oracle accepts zig-js's proposal grammar.

Validation:

  • parser module: 236/236
  • focused frontend boundary: 1/1
  • raw JavaScriptCore differential: 6/6 byte-identical messages
  • exact-parent test262 comparison: 8,456 pass / 64 known fail before and after across expression-class, expression-super, and statement-class; both 32-path failure inventories are identical (0 flips)

This reduces direct return ParseError.UnexpectedToken; sites from 54 to 50; the invalid-property switch arm was also structured.

Sign in to comment on this issue.