Parent: #459
Problem
When an Intl option gets an out-of-range value, JavaScriptCore enumerates the legal values. zig-js emits a generic template with no list — and does so via two different templates, one of which drops the offending value entirely. A differential over the Intl surface found 19 cases from this single helper.
| source | zig-js | JavaScriptCore |
|---|---|---|
new Intl.DateTimeFormat('en', {hour:'bogus'}) | invalid value 'bogus' for option hour | hour must be "2-digit" or "numeric" |
new Intl.DateTimeFormat('en', {dateStyle:'bogus'}) | invalid value 'bogus' for option dateStyle | dateStyle must be "full", "long", "medium", or "short" |
new Intl.NumberFormat('en', {style:'bogus'}) | invalid value for option style | style must be either "decimal", "percent", "currency", or "unit" |
new Intl.PluralRules('en', {type:'bogus'}) | invalid value for option type | type must be "cardinal" or "ordinal" |
Details that matter for exact parity
- Values are double-quoted, with an Oxford comma before the final
or. - JSC includes the word "either" for some options and not others, and it does not
correlate with the number of choices. Observed WITH "either":
formatMatcher,localeMatcher,usage,numeric,fallback,style. Observed WITHOUT:hour,dateStyle,type. This has to be per-option data, not a rule derived from the value count. - zig-js is internally inconsistent today and should be unified first regardless of
wording: 13 cases use
invalid value '<v>' for option <name>and 6 useinvalid value for option <name>, silently dropping the value the user passed (style,notation,currencyDisplay,roundingMode,localeMatcher, andPluralRulestype).
Suggested shape
The option-reading helper already knows the allowed set — it validates against it. Have it render the list, and carry a per-option "either" flag. One helper, one fix.
Verification
scratchpad/sweep/probe.sh diffs zig-js against a real JavaScriptCore backend. Drive
probes from inside a function: zig-js --eval runs script code, so an indirect eval
shares global scope with the harness and a case declaring var i truncates the run.