Conversation
…et_method_list
Two fixes surfaced by `jcpan -t MooseX::Types`:
1. Parser: inside ${...}, a leading single quote starts a string literal,
not the legacy $'foo => $main::foo package separator. Previously,
\%{'Foo::'} parsed as the bogus identifier ::Foo::' and resolved to a
different (empty) stash from \%{"Foo::"}. Net effect: keys %Foo::
listed entries that exists ${'Foo::'}{name} could not find, and
delete ${'Pkg::'}{name} did not invalidate Pkg->can("name"). This
broke MooseX::Types' t/16_introspection.t. Fix in
IdentifierParser.parseComplexIdentifierInner: when insideBraces and
the first token is ', return null so parseBracedVariable falls
through to parseBlock and evaluates the string literal.
2. namespace::autoclean: _method_check unconditionally called
$meta->get_method_list whenever Class::MOP::class_of returned a
metaobject. For non-class packages that yields a bare
Class::MOP::Package (no HasMethods mixin), producing a
"Can't locate object method get_method_list" warning on every
on_scope_end callback. Guard with $meta->can('get_method_list')
and fall through to the plain-class detection otherwise.
After: MooseX-Types 0.51 goes from Files=20, Tests=250, FAIL (1 fail +
warning spam after every test) to PASS with no warnings.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.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
Two fixes uncovered by
jcpan -t MooseX::Types:1. Parser:
${'Pkg::'}must be a string literal, not legacy$'fooInside
${...}braces, a leading'starts a string literal expression. Previously the parser still applied the legacy single-quote-as-package-separator rule (used for unbraced$'foo=>$main::foo), so\%{'Foo::'}parsed as the bogus identifier::Foo::'and resolved to a different, empty stash from\%{"Foo::"}.Concrete symptoms:
keys %Foo::listed an entry, butexists ${'Foo::'}{name}returned false.delete ${'Pkg::'}{name}did not invalidatePkg->can("name")— the deleted-but-still-callable sub broke MooseX::Types't/16_introspection.t.Fix in
IdentifierParser.parseComplexIdentifierInner: wheninsideBracesis true and the first token is', returnnullsoparseBracedVariablefalls through toparseBlock, which evaluates the string literal correctly. The unbraced legacy$'foopath is unchanged.2.
namespace::autoclean: guardget_method_list_method_checkunconditionally called$meta->get_method_listwheneverClass::MOP::class_of($package)returned a metaobject. For non-class packages the metaobject is a bareClass::MOP::Package(noHasMethodsmixin), producingon every
on_scope_endcallback. Now guarded with$meta->can('get_method_list'), falling through to the plain-class subname-based detection otherwise.Result
MooseX-Types-0.51: wasFiles=20, Tests=250, Result: FAIL(1 failure + warning spam after every test). NowResult: PASSwith no warnings.Test plan
make(full unit suite) passes./jcpan -t MooseX::Types-> all 20 test files PASS, 250/250 tests\%{'Foo::'}and\%{"Foo::"}now refer to the same stash;delete ${'Pkg::'}{name}properly invalidatesPkg->can("name").Generated with Devin