Skip to content

fix: parser flag leak in \@{&func} and caller() hasargs tracking#501

Merged
fglock merged 2 commits intomasterfrom
fix/math-base-convert-bugs
Apr 13, 2026
Merged

fix: parser flag leak in \@{&func} and caller() hasargs tracking#501
fglock merged 2 commits intomasterfrom
fix/math-base-convert-bugs

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 13, 2026

Summary

Three fixes to make Math::Base::Convert pass 20/20 test programs (5350 subtests):

  • Parser: \@{&func} flag leakparsingTakeReference leaked from \ into @{...} block parsing, causing &func inside \@{&func} to be treated as a CODE reference instead of being called. Fixed by save/restore in parseBracedVariable(), following the existing pattern for insideBracedDereference.

  • Runtime: caller()[4] hasargs tracking — Added hasArgsStack (ThreadLocal) to track whether each call frame created a fresh @_. The 2-arg instance apply() (shared args / &func no parens) pushes false; the 3-arg instance apply() (fresh args / func()) pushes true. callerWithSub() reads from this stack instead of the old name-based heuristic. Math::Base::Convert relies on this in hex/oct overrides to distinguish oct("string") from &oct.

  • Bundle diagnostics.pm — Imported via sync.pl with an @INC search patch for Pod/perldiag.pod (capital P, as stored in the JAR).

See dev/modules/math_base_convert.md for detailed analysis of all three bugs with AST comparisons, code path walkthroughs, and Perl 5 semantics tables.

Test plan

  • make passes (all unit tests)
  • ./jcpan -t Math::Base::Convert — 20/20 test programs, 5350 subtests pass
  • Bug 1 verified: \@{&func} returns correct array ref
  • Bug 2 verified: caller(0)[4] returns empty for &func, 1 for func()

Generated with Devin

fglock and others added 2 commits April 13, 2026 14:19
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>
@fglock fglock force-pushed the fix/math-base-convert-bugs branch from 52bad3a to d1b5c6b Compare April 13, 2026 12:19
@fglock fglock merged commit 0d83f6c into master Apr 13, 2026
2 checks passed
@fglock fglock deleted the fix/math-base-convert-bugs branch April 13, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant