Skip to content

fix: B module improvements and do FILE $@ fix for Future 0.52 compatibility#465

Merged
fglock merged 2 commits into
masterfrom
docs/future-module-plan
Apr 9, 2026
Merged

fix: B module improvements and do FILE $@ fix for Future 0.52 compatibility#465
fglock merged 2 commits into
masterfrom
docs/future-module-plan

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 9, 2026

Summary

Three fixes that improve Future 0.52 compatibility from 36/56 to 41/56 test programs passing (105 -> 32 failing subtests, 70% reduction):

1. B::SV::REFCNT returns 1 (was 0)

Aligns with Internals::SvREFCNT and Devel::Peek::SvREFCNT which already return 1. Fixes ~73 subtests where Test2::Tools::Refcount::is_oneref() was failing.

2. B module optree walking fixes

  • B::OP::next returns B::NULL (was undef) to terminate optree walks correctly
  • Added B::COP class with file/line methods for proper introspection
  • B::CV::START returns B::COP so code like Future.pm's CvNAME_FILE_LINE() works
  • B::NULL::next returns self to prevent infinite loops

This eliminates 4 test crashes (exit 255) where Future.pm called $cop->file on undef.

3. do FILE clears $@ after successful execution

Perl's do FILE behaves like eval STRING and clears $@ on success. PerlOnJava was not clearing $@ after successful execution, causing $@ from inner eval { die ... } blocks to leak to the caller.

Remaining failures (all unfixable JVM limitations)

  • 26 subtests expect refcount=2 (JVM has no reference counting)
  • 3 subtests require DESTROY (JVM uses tracing GC)
  • 2 minor issues (caller line number, exit handling)

Test plan

  • make passes (all unit tests)
  • ./jcpan -t Future results: 41/56 programs pass, 32/778 subtests fail
  • All 4 previously-crashing tests now pass cleanly
  • $@ leakage verified fixed with direct test

Generated with Devin

fglock and others added 2 commits April 9, 2026 08:27
Analysis of `./jcpan -t Future` results: 36/56 test programs pass,
105/763 subtests fail. Root causes identified:

- P0: B::SV::REFCNT returns 0 instead of 1 (~100 subtests)
- P1: B::OP::next returns undef instead of B::NULL (4 crashes)
- P2: DESTROY not implemented (3 subtests, JVM limitation)
- P3: $@ leakage after dies{} (1 crash)

Fix plan: Phase 1 (REFCNT=1) and Phase 2 (B::NULL) are trivial
one-line changes that should fix ~60 subtests and 4 crashes.

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Three fixes that improve Future 0.52 compatibility from 36/56 to 41/56
test programs passing (105 -> 32 failing subtests):

1. B::SV::REFCNT returns 1 instead of 0, aligning with
   Internals::SvREFCNT and Devel::Peek::SvREFCNT stubs

2. B::OP::next returns B::NULL (not undef) to terminate optree
   walks correctly. Added B::COP class with file/line methods
   and B::CV::START now returns B::COP for proper introspection

3. do FILE now clears $@ after successful execution, matching
   Perl semantics where do FILE behaves like eval STRING

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

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock changed the title docs: Future 0.52 compatibility plan fix: B module improvements and do FILE $@ fix for Future 0.52 compatibility Apr 9, 2026
@fglock fglock merged commit d667d9d into master Apr 9, 2026
2 checks passed
@fglock fglock deleted the docs/future-module-plan branch April 9, 2026 07:49
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