Skip to content

fix: case-sensitive resolution of same-spelling variables (issue #434)#629

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

fix: case-sensitive resolution of same-spelling variables (issue #434)#629
rexm merged 2 commits into
masterfrom
worktree-agent-a851b66a6044e2a1a

Conversation

@rexm

@rexm rexm commented Jun 20, 2026

Copy link
Copy Markdown
Member

Fixes #434

When multiple variables share the same spelling but differ in case (e.g. TEST vs test), each now resolves to its own correctly-cased property.

Root cause

configuration.Helpers uses a FixedSizeDictionary with a PathInfoLightEqualityComparer that compares keys case-insensitively. When {{TEST}} is compiled first, a LateBindHelperDescriptor keyed to TEST is stored. When {{test}} is compiled next, TryGetValue finds the TEST entry (same bucket), and the cached descriptor — which resolves TEST at runtime — is reused unchanged. So both expressions resolve the same TEST property.

Fix

In PathBinder.VisitPathExpression, after a successful TryGetValue, check whether the found entry is a LateBindHelperDescriptor whose stored Name.Path differs (by ordinal) from the current pathInfo.Path. If so, create a new LateBindHelperDescriptor with the correct case. The new descriptor is used for this expression only (not re-stored in the dictionary, since the case-insensitive slot is already occupied).

Test plan

  • New test Issue434_CaseSensitiveLookupWithSameSpellingVariables in source/Handlebars.Test/Issues/Issue434Tests.cs — confirmed red before fix, green after
  • Full test suite: 1747 tests, 0 failures

🤖 Generated with Claude Code

rexm and others added 2 commits June 20, 2026 08:23
When multiple variables share the same spelling but differ only in case
(e.g. TEST vs test), the helpers dictionary's case-insensitive lookup
could return a LateBindHelperDescriptor cached for a differently-cased
path. This caused {{test}} to resolve to the value of TEST. Fix detects
this mismatch in PathBinder and creates a fresh LateBindHelperDescriptor
carrying the exact casing of the current expression.

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

Copy link
Copy Markdown

@rexm rexm merged commit ab3ce76 into master Jun 20, 2026
7 checks passed
@rexm rexm deleted the worktree-agent-a851b66a6044e2a1a branch June 20, 2026 13:06
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.

The first parameter match/unmatch will overwrite all the subsequent same-spelling match/unmatch

1 participant