fix: Assert plugin always throws on defined values (GH #300)#338
Draft
Koan-Bot wants to merge 1 commit intoabw:masterfrom
Draft
fix: Assert plugin always throws on defined values (GH #300)#338Koan-Bot wants to merge 1 commit intoabw:masterfrom
Koan-Bot wants to merge 1 commit intoabw:masterfrom
Conversation
Template::Monad::Assert::AUTOLOAD was passing $stash instead of $this to dotop(), causing it to look up the item in the root stash rather than in the actual hash/list being asserted on. For example, [% foo.assert.bar %] would look for 'bar' in the stash root (where it doesn't exist) instead of in foo, always throwing "undefined value for bar" even when foo.bar is defined. Added 6 tests covering defined-value pass-through for hashes, nested hashes, arrays, and direct stash variable access. Fixes abw#300 Co-Authored-By: Kōan <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
Fixes the
Template::Plugin::Assertvmethod which always threw "undefined value" errors even when the asserted value was defined.Root cause:
Template::Monad::Assert::AUTOLOADpassed$stashinstead of$thistodotop(), causing lookups to search the root stash rather than the hash/list being asserted on.Example:
[% foo.assert.bar %]wherefoo = { bar => 999 }would incorrectly throw because it looked forbarin the stash root instead of infoo.Changes
Template::Monad::Assert::AUTOLOADhash.assert.foo)nested.assert.name,nested.assert.deep.value)items.assert.size,items.assert.first)assert.name)Test plan
Fixes #300
🤖 Generated by Kōan