Parent: #899
Problem
Thirteen static/dynamic import grammar sites in parseImportDecl, parseNamedImports, and parseImportExpr still return bare parser tags.
Executed on current main (c06af28), the five dynamic-import sites differ from raw JavaScriptCore 625.1.22:
| source | zig-js | JavaScriptCore |
|---|---|---|
import.1 | Unexpected number '.1' | Unexpected number '.1'. import call expects one or two arguments. |
Script import.meta | UnexpectedToken at 1:12 | import.meta is only valid inside modules. |
import.\\u006deta | UnexpectedToken at 1:17 | Unexpected identifier '\\u006deta'. "import." can only be followed with meta. |
import.foo('x') | UnexpectedToken at 1:11 | Unexpected identifier 'foo'. "import." can only be followed with meta. |
import() / leading or second-argument spread | bare UnexpectedToken | exact unexpected ) / ... token |
A direct Parser.parseModule probe confirms eight static-import shapes all fall back to UnexpectedToken, including forbidden default/source/namespace/named bindings, a missing string module specifier, a missing named-import local after as, and a string import name without as. Node's Module parser independently confirms all eight are grammar errors; raw JSC's public C API has no Module parse entry point, so no unsupported message-parity claim is made for those static forms.
Implementation
- Give all 13 bare returns structured reasons and exact retained tokens.
- Match raw JavaScriptCore prose for the dynamic-import forms.
- Use clear token-specific prose for static Module forms while preserving standards-correct acceptance.
- Preserve compact
ParseErrorcategories and keep formatting on failure paths. - Do not infer grammar context by rescanning source or add legacy fallbacks.
Verification
- Pin reason, message, and byte offset with both Script and Module parser tests.
- Add a focused production boundary case for eval-visible dynamic-import messages.
- Re-run the eight static forms against Node as the grammar oracle.
- Compare exact-parent test262 dynamic-import and module-code subtrees, reporting denominators and flips.