fix: correct DEFAULT assignment for array elements in Context stash - #460
Draft
toddr-bot wants to merge 1 commit into
Draft
fix: correct DEFAULT assignment for array elements in Context stash#460toddr-bot wants to merge 1 commit into
toddr-bot wants to merge 1 commit into
Conversation
…tash
In _assign(), the default-value guard for array elements used hash
access ($root->{$item}) instead of array access ($root->[$item]).
This caused DEFAULT assignments to always overwrite existing array
values because hash access on an array ref returns undef.
Also fix 'Experimetal' typo in POD heading.
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.
What
Fix a bug in
Template::Stash::Context::_assign()where DEFAULTassignment on array elements always overwrote existing values.
Why
The
$defaultguard on line 625 used hash access ($root->{$item})on an array ref instead of array access (
$root->[$item]). Hash accesson an array ref always returns
undef, so the guard never triggered —DEFAULT list.0 = 'x'would silently overwrite an existing value atindex 0.
The parent class
Template::Stashhas the correct$root->[$item]on the equivalent line 620.
How
One-character fix:
{→[and}→]. Also fixed a "Experimetal"typo in the POD heading.
Testing
_assign()API (verify existing values preserved, undefined slotsfilled)
DEFAULT mylist.0 = 'x'viatest_expectwith the Context stashQuality Report
Changes: 2 files changed, 35 insertions(+), 2 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan