Skip to content

fix: allow Unicode letters as first character in identifiers (issue #416)#620

Merged
rexm merged 2 commits into
masterfrom
worktree-agent-afe0501761accd5d4
Jun 20, 2026
Merged

fix: allow Unicode letters as first character in identifiers (issue #416)#620
rexm merged 2 commits into
masterfrom
worktree-agent-afe0501761accd5d4

Conversation

@rexm

@rexm rexm commented Jun 20, 2026

Copy link
Copy Markdown
Member

Fixes #416

Summary

  • {{姓}} (and any template expression whose identifier starts with a non-ASCII Unicode letter) previously failed with "Reached unparseable token in expression: 姓}}".
  • The root cause was in WordParser.IsWord() in source/Handlebars/Compiler/Lexer/Parsers/WordParser.cs: the check only accepted characters from a hard-coded ASCII set (ValidWordStartCharacters) and never fell through to accept Unicode letters.
  • Fix: added || char.IsLetter(c) to the start-character check so any Unicode letter (as defined by System.Char) is a valid identifier start — matching Handlebars.js behaviour.
  • Continuation characters already accepted Unicode letters (the AccumulateWord loop only stops on }, ~, ), =, or whitespace), so {{a姓}} already worked — only the first character was broken.

Changes

  • source/Handlebars/Compiler/Lexer/Parsers/WordParser.cs — one-line fix in IsWord()
  • source/Handlebars.Test/IssueTests.cs — regression test Issue416_UnicodeFirstCharacterInIdentifier

Test plan

  • New test Issue416_UnicodeFirstCharacterInIdentifier fails before the fix and passes after.
  • Full suite (1747 tests) passes with no regressions.

🤖 Generated with Claude Code

rexm and others added 2 commits June 19, 2026 20:54
)

The WordParser's IsWord check previously only recognized ASCII letters and
a fixed set of special characters as valid identifier start characters. Any
Unicode letter (e.g. Japanese kanji like 姓) at the start of a Handlebars
expression would fail with "Reached unparseable token in expression". The fix
adds char.IsLetter(c) to the start-character check so any Unicode letter is
accepted, matching the behaviour of Handlebars.js.

Fixes #416

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rexm rexm enabled auto-merge June 20, 2026 21:49
@sonarqubecloud

Copy link
Copy Markdown

@rexm rexm merged commit 462a5b0 into master Jun 20, 2026
7 checks passed
@rexm rexm deleted the worktree-agent-afe0501761accd5d4 branch June 20, 2026 21:59
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.

Is UTF-8 supported inside placeholders ?

1 participant