Parent: #899
Problem
Five statement-parser exits discard grammar context in parseDoWhile, parseSwitch, parseThrow, and parseTry: four return a bare UnexpectedToken and one returns a bare ExpectedToken.
Executed on current main (40e64ef), nine representative eval probes expose internal tags. Raw JavaScriptCore 625.1.22 reports:
- duplicate
defaultand an invalid switch-body item as an unexpected exact token followed byExpected '}' to end a body of a 'switch'. - a line terminator after
throwasCannot have a newline after 'throw'. try {}at EOF asUnexpected end of script, and a non-EOF follower as an unexpected exact token followed byTry statements must have at least a catch or finally block.- a missing
whileafterdoasUnexpected end of scriptat EOF, or an unexpected exact token followed byExpected 'while' to end a do-while loop.
Implementation
- Retain the current switch-body token, try follower, and do-while follower.
- Attach the restricted-production failure to its consumed
throwkeyword. - Let the existing EOF diagnostic mapping produce
Unexpected end of script. - Match raw JavaScriptCore prose and preserve compact
ParseErrorcategories. - Add no allocation or source scan to successful statement parsing.
Verification
- Pin reason, message, and byte offset for all nine probes.
- Add a focused production eval case for each message/token family.
- Compare exact-parent switch, throw, try, and do-while test262 subtrees with nonzero denominators and report flips.