fix: parser flag leak in \@{&func} and caller() hasargs tracking#501
Merged
fix: parser flag leak in \@{&func} and caller() hasargs tracking#501
Conversation
PerlOnJava's ExtUtils::MakeMaker only scanned root-level .pm files as a fallback when lib/ found nothing. Distributions like Math::Base::Convert that have the main .pm at the root alongside sub-modules in lib/ would silently drop the main module file. Now root-level .pm files and BASEEXT directories are always scanned (with dedup), matching real MakeMaker's PMLIBDIRS behavior. Before: Math::Base::Convert 0/20 tests pass (Can't locate Convert.pm) After: Math::Base::Convert 15/20 tests pass Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Three fixes to pass Math::Base::Convert 20/20 tests:
1. Parser: save/restore parsingTakeReference in parseBracedVariable()
before block parsing. The \ operator's flag leaked into @{...} blocks,
causing \@{&func} to treat &func as a CODE ref instead of calling it.
2. Runtime: track hasargs per call frame via hasArgsStack (ThreadLocal).
caller()[4] now correctly returns false for &func (no parens) calls
that inherit the caller's @_, and true for func(args) calls with
fresh @_. Math::Base::Convert relies on this in hex/oct overrides.
3. Bundle diagnostics.pm with @inc search patch for Pod/perldiag.pod.
Generated with [Devin](https://cli.devin.ai/docs)
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
52bad3a to
d1b5c6b
Compare
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
Three fixes to make Math::Base::Convert pass 20/20 test programs (5350 subtests):
Parser:
\@{&func}flag leak —parsingTakeReferenceleaked from\into@{...}block parsing, causing&funcinside\@{&func}to be treated as a CODE reference instead of being called. Fixed by save/restore inparseBracedVariable(), following the existing pattern forinsideBracedDereference.Runtime:
caller()[4]hasargs tracking — AddedhasArgsStack(ThreadLocal) to track whether each call frame created a fresh@_. The 2-arg instanceapply()(shared args /&funcno parens) pushesfalse; the 3-arg instanceapply()(fresh args /func()) pushestrue.callerWithSub()reads from this stack instead of the old name-based heuristic. Math::Base::Convert relies on this inhex/octoverrides to distinguishoct("string")from&oct.Bundle
diagnostics.pm— Imported viasync.plwith an@INCsearch patch forPod/perldiag.pod(capital P, as stored in the JAR).See
dev/modules/math_base_convert.mdfor detailed analysis of all three bugs with AST comparisons, code path walkthroughs, and Perl 5 semantics tables.Test plan
makepasses (all unit tests)./jcpan -t Math::Base::Convert— 20/20 test programs, 5350 subtests pass\@{&func}returns correct array refcaller(0)[4]returns empty for&func,1forfunc()Generated with Devin