Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/unreleased/1580.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `media/json/tokenizer`: removes `parseMinusState`'s unreachable `case '-'`
arm — the JS tokenizer always merges adjacent `-` into a single `'--'`
token, bringing the module to 100% line/branch/function coverage
5 changes: 4 additions & 1 deletion fjs/media/json/tokenizer/module.f.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ const parseDefaultState = input => {
const parseMinusState = input => {
if (input === null) return [[{ kind: 'error', message: 'invalid token' }], { kind: 'def' }]
switch (input.token.kind) {
case '-': return [[{ kind: 'error', message: 'invalid token' }], { kind: '-' }]
// negation is lexical: the minus sign joins the lexeme, so the token
// stays the exact source text of the JSON number.
case 'number': return [[{ kind: 'number', value: `-${input.token.value}` }], { kind: 'def' }]
// No `'-'` case: the underlying JS tokenizer always merges adjacent
// `-` characters into a single `'--'` token (see `js/tokenizer`), so
// this state never sees a second `'-'` — a run of `-` past the first
// always falls through to the `default` arm below instead.
default: return [{ first: { kind: 'error', message: 'invalid token' }, tail: mapToken(input.token) }, { kind: 'def' }]
}
}
Expand Down
Loading