Parent: #899
Problem
Nine direct bare exits in cookTemplateQuasi and validateTemplateEscape collapse malformed untagged template escapes to ParseError.UnexpectedToken. The parser has already identified both the escape family and its byte cursor, but discards both before the eval boundary.
Executed on current main (1ffe681), all 17 probes differ from raw JavaScriptCore 625.1.22:
- malformed
\xforms (3 first-quasi forms plus one tail after a substitution): zig-js emitseval: UnexpectedToken at ...; JSC emits\x can only be followed by a hex character sequence - malformed fixed and braced
\uforms (10): zig-js emits the tag; JSC emits\u can only be followed by a Unicode character sequence \00,\8, and\9(3): zig-js emits the tag; JSC emitsThe only valid numeric escape in strict mode is '\0'
Tagged templates must continue accepting these escape sequences with an undefined cooked value.
Implementation
- Return the exact diagnostic family and invalid-escape cursor from the existing validation pass.
- Attach the diagnostic at the offending backslash for first, middle, and tail quasis, including templates whose earlier CR/CRLF bytes were normalized.
- Match raw JavaScriptCore prose for the three families.
- Preserve tagged-template semantics and keep all diagnostic formatting on failure paths.
- Do not rescan the complete source or add a legacy fallback.
Verification
- Pin reason, message, and byte offset for all existing malformed cases plus a failing tail after a substitution.
- Pin valid tagged forms with undefined cooked values.
- Add a focused production eval case for all three messages.
- Compare exact-parent
test/language/expressions/template-literalandtest/language/expressions/tagged-templateruns, reporting denominators and flips.