Skip to content

Fix bytecode my-extraction, stat on filehandles, and signatures.t regression#246

Merged
fglock merged 2 commits intomasterfrom
fix-bytecode-my-extraction
Feb 27, 2026
Merged

Fix bytecode my-extraction, stat on filehandles, and signatures.t regression#246
fglock merged 2 commits intomasterfrom
fix-bytecode-my-extraction

Conversation

@fglock
Copy link
Owner

@fglock fglock commented Feb 27, 2026

Summary

  • Bytecode my-extraction in short-circuit ops: Extract my declarations before conditional jumps in &&/||/// so variables are always initialized to undef even when the branch is short-circuited (e.g., my $x = expr if COND)
  • AUTOLOAD with forward declarations: Fix AUTOLOAD dispatch when a forward-declared stub exists — use InheritanceResolver to find the real AUTOLOAD in the inheritance chain
  • Stat/file tests on filehandles: Store filePath in RuntimeIO at open() time so stat($fh) and -f $fh work correctly instead of returning EBADF
  • stat _ parsing: Move the special _ handler before the ALLCAPS bareword check in OperatorParser.parseStat() so stat _ uses the last-stat buffer
  • stat _ / lstat _ cached buffer: Use cached stat attributes instead of re-statting; return EBADF when no prior stat succeeded
  • Signatures.t regression fix: Move package inheritance from BytecodeCompiler.compile() to EmitterMethodCreator.compileToInterpreter() — the generic compile() path was clobbering the correct eval STRING package set by setCompilePackage(), breaking 155 signature tests
  • Signature error messages: Use "expected N" instead of "expected at most/least N" when min == max parameters

Test plan

  • ./gradlew test passes
  • t/op/signatures.t: 307 failures (down from 462 regression, matching baseline)
  • t/op/stat_errors.t: 0 failures
  • ExifTool.t: 30/35 pass

Generated with Devin

fglock and others added 2 commits February 27, 2026 08:28
stat _ and lstat _ now use the cached stat buffer instead of
re-statting the last filename. Returns EBADF when no prior stat
succeeded, matching Perl behavior.

Added STAT_LASTHANDLE/LSTAT_LASTHANDLE bytecode opcodes so the
bytecode compiler correctly handles stat _ (previously compiled
_ as a bareword string, causing stat on filename "_").

Both JVM and bytecode paths now pass calling context to
statLastHandle/lstatLastHandle so scalar context correctly
returns empty string on failure.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
Two fixes:

1. Move package inheritance from BytecodeCompiler.compile() to
   EmitterMethodCreator.compileToInterpreter(). The compile() method
   is called by all paths including eval STRING (RuntimeCode and
   EvalStringHandler), which already set the package correctly via
   setCompilePackage(). The unconditional override in compile()
   clobbered the correct package with the post-parse symbolTable
   package, breaking 155 signature tests that use eval().

2. Fix signature error messages: use "expected N" instead of
   "expected at most/least N" when min == max parameters.

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <noreply@cognition.ai>
@fglock fglock changed the title Fix stat _ / lstat _ regression in stat_errors.t Fix bytecode my-extraction, stat on filehandles, and signatures.t regression Feb 27, 2026
@fglock fglock merged commit 4bd2f44 into master Feb 27, 2026
2 checks passed
@fglock fglock deleted the fix-bytecode-my-extraction branch February 27, 2026 08:06
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