Repository navigation
Conversation
fix: resolve block params named like @-variables by name
Unrelated to the JsonNode changes in this PR. The new JSON array iteration tests use `as |item index|`, which exposed this bug as an intermittent CI failure.
A block param that shares a name with a context variable (e.g. `{{#each items as |item index|}}`) was looked up in BlockParamsObject using the entry index of the matching @-variable in ContextDataObject. The two dictionaries usually place the key in the same slot, so this mostly worked, but when a hash collision moved the @-variable's slot, the lookup returned another block param's value or nothing. String hashes are randomized per process, so the failure was intermittent on every OS.
Look block params up by segment, as TryGetContextVariable already does. Adds a regression test covering index, key, first, last, root and parent. Because the bug depends on the process hash seed, the test cannot fail deterministically without the fix.
This branch has not been deployed
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.
Block parameters such as
indexcould resolve to another parameter’s value or nothing. The lookup reused an entry index fromContextDataObjectagainstBlockParamsObject, where hash collisions could place the same name in a different slot.Resolve block parameters by name, matching
TryGetContextVariable.Adds regression coverage for
index,key,first,last,root, andparent. Reproducing the original failure depends on the process’s randomized string hash seed.Validation: all 5 focused test cases pass.
Split from #670.