test: regression guard for block params in nested with/each (issue #595)#636
Merged
Conversation
Adds Issue595Tests.cs with four regression tests covering the reported
NotSupportedException: TypeConverter cannot convert UndefinedBindingResult
when using {{#with this as |field|}} inside {{#each Fields}} and passing
`field` to a helper in a nested {{#each (helper field)}}.
All four tests pass on the current codebase, confirming the bug is not
reproducible. The FixedSizeDictionary.Reset() version-bump mechanism
(OptionalClear) already prevents stale block-param values from leaking
across BindingContext pool reuse cycles.
Includes a 1000-iteration stress test to exercise pool reuse under load.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Closes #595
This PR adds regression tests in
source/Handlebars.Test/Issues/Issue595Tests.csfor the reportedNotSupportedException: TypeConverter cannot convert UndefinedBindingResultwhen using{{#with this as |field|}}inside{{#each Fields}}and then passingfieldto a helper inside a nested{{#each (helper field)}}.Findings: Bug is NOT reproducible in current code
Two previous agents investigated this issue and could not reproduce the exception. This agent confirmed the same conclusion:
BindingContextpool reuse (the claimed root cause)FixedSizeDictionary.OptionalClear()path (called when returning aBindingContextto the pool) increments_version, which invalidates allEntryIndexobjects from the previous use. Subsequent lookups viaTryGetValue(in EntryIndex<TKey> keyIndex, ...)checkkeyIndex.Version != _versionand correctly returnfalse— so stale block-param slots from prior pool tenants are never served to new callers300f2f6 Improve object pool safetycommit (Mar 2022) and8a58d30 fix: prevent unbounded DictionarySlim growth when replacing existing keys (issue #541)commit are the likely fixes that made this class of bug non-reproducible on currentmainTests added
BlockParamFromWithShouldBePassableToHelperInInnerEachUndefinedBindingResult)BlockParamTypedAccessShouldNotThrowWhenPassedToHelperarguments.At<string>(0)(typed access) which would throwNotSupportedExceptionif the value wereUndefinedBindingResultBlockParamFromWithShouldBePassableToHelperInInnerEachMultipleIterationsIssue595_WithBlockParamsInEach_DoesNotThrowTest plan
dotnet test --filter "Issue595"— 4/4 passed🤖 Generated with Claude Code