Skip to content

fix(lexer): accept identifiers that start with digits - #1201

Merged
jknack merged 1 commit into
jknack:masterfrom
princejain756:fix/digit-leading-identifiers
Oct 23, 2026
Merged

jknack merged 1 commit into
jknack:masterfrom
princejain756:fix/digit-leading-identifiers

Conversation

@princejain756

Copy link
Copy Markdown
Contributor

Fixes #1078

{{24HrServicePh}} fails to parse with found: '{{', expected: '<EOF>' while handlebars.js renders it fine. The lexer tokenizes 24HrServicePh as PATH, but sexpr (the statement head for var, blocks, subexpressions) only accepts QID - PATH is only allowed in partial names via pexpr.

Rather than widening every parser rule that consumes sexpr.QID() (the visitor calls it in about 10 places, so a PATH alternative would need null-handling throughout), this change teaches the ID lexer fragment to accept digit-leading identifiers: [0-9]+ ID_START ID_SUFFIX*. 24HrServicePh now lexes as QID, which sexpr, refParam, and END_BLOCK nameEnd already accept.

Pure numeric literals are unaffected: 24 and 24.5 contain no ID_START after the digits, so they still match NUMBER. Verified: {{24Hr}} renders the context value, {{#if 24Hr}} blocks work, {{foo 24}}/{{foo 24.5}} still parse as number params.

Tests: new Issue1078 class covering the variable case, a block-helper case, and numeric literal parameters. Module suite: 1043 tests, zero regressions (the 3 DateFormatTest failures are a pre-existing locale issue, identical on a clean master checkout).

One scoping note: bare {{24}} as a standalone expression still fails (NUMBER was never a sexpr head, same on 4.5.5) - that is a different grammar question and out of scope here.

@jknack jknack added this to the 4.5.6 milestone Oct 23, 2026
@jknack
jknack merged commit f4101d0 into jknack:master Oct 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expressions that start with numbers fail parsing

2 participants