fullwide/hanidec numberingSystem: digit matcher and decoder tables have drifted apart, causing silent data corruption
Describe the bug
src/impl/digits.js keeps two independently-authored representations per numbering system: a regex character class used to recognize a digit, and a code-point range/char array used to decode it. Two of these have drifted out of sync, and parseDigits() has no fail-closed branch, so a recognized-but-undecodable character silently corrupts the parsed value while the resulting DateTime/Duration still reports isValid: true:
fullwideoff-by-two. The matcher[0-9]accepts U+FF10–U+FF19 (all ten full-width digits), but the decoder rangenumberingSystemsUTF16.fullwideis[65296, 65303](only up to U+FF17). Full-width8/9(U+FF18/U+FF19) match as digits but decode to nothing — they're silently dropped from the accumulator.- Literal
|inside thehanideccharacter class. The source string"[〇|一|二|三|四|五|六|七|八|九]"puts a literal|inside a character class (where it has no alternation meaning), so the compiled regex matches an ordinary pipe as a "digit." MeanwhilehanidecCharsstrips|when building the decode array, sohanidecChars.indexOf("|")returns-1, andvalue += -1string-concatenates a literal"-1"into the parsed number.
To Reproduce
import { DateTime } from 'luxon';
const dt1 = DateTime.fromFormat('2018-01-01', 'yyyy-MM-dd', { numberingSystem: 'fullwide' });
console.log(dt1.year, dt1.isValid); // -> 201 true (should be 2018, or Invalid)
const dt2 = DateTime.fromFormat('|', 'y', { numberingSystem: 'hanidec' });
console.log(dt2.year, dt2.isValid); // -> -1 trueVerified against the actual 3.7.2 source; output matches exactly.
Actual vs Expected behavior
Actual: 2018 parses to year 201 (the full-width 8 vanishes); a lone | parses to -1 — both report isValid: true with no invalidReason.
Expected: either these characters decode correctly, or the parse should fail (isValid: false) rather than silently emitting a value the input never contained.
Desktop (please complete the following information):
- Luxon version: 3.7.2 (current latest; verified against source at GitHub tag
3.7.2) - Node: v24.16.0
Additional context
Suggested fix:
- Correct the
fullwidedecoder range to[65296, 65305]. - Remove the literal pipes from the
hanideccharacter class:"[〇一二三四五六七八九]". - Make
parseDigitsfail closed: if a matched character can't be resolved by any decoder table (or resolves toindexOf's-1sentinel), returnNaNfor the whole parse instead of silently dropping/misinterpreting the character. - A regression test round-tripping all ten digits for every supported
numberingSystem, plus explicit rejection tests for|/[/]underhanidec, would catch regressions here.
Source: moment/luxon