Skip to content

fix(parser): make dump an overridable core operator#612

Merged
fglock merged 1 commit intomasterfrom
fix/dump-overridable
Apr 29, 2026
Merged

fix(parser): make dump an overridable core operator#612
fglock merged 1 commit intomasterfrom
fix/dump-overridable

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 29, 2026

Summary

Make Perl's dump builtin overridable so modules that export their own dump sub (notably Data::Dump) can be loaded.

PerlOnJava's parser was unconditionally throwing Not implemented: operator: dump before checking for a user override, which broke any module that imports a dump sub. Concretely, Data::Dump declares use subs qw(dump) and exports dump via Exporter; inside Data/Dump.pm itself calls like dump(@_) (line 82, in sub dd) hit the parser's hardcoded reject path:

Error:  Not implemented: operator: dump at .../Data/Dump.pm line 82, near "(@_"

This blocks any CPAN distribution that uses Data::Dump, which is how I found it: jcpan -t CPU::Z80::Assembler::Token failed at the use Data::Dump; line.

Fix

Add "dump" to ParserTables.OVERRIDABLE_OP. The existing override path in ParsePrimary (which already handles use subs, Exporter typeglob assignment, and CORE::GLOBAL::*) is now consulted before CoreOperatorResolver raises the unimplemented-op error.

CORE_PROTOTYPES still maps dump"", so an explicit CORE::dump() keeps hitting the unimplemented path — only user/imported dump subs resolve to the imported sub.

Test plan

  • t/Token-new.t from CPU-Z80-Assembler-2.10 passes 32/32 (previously aborted at use CPU::Z80::Assembler::Token because Data::Dump failed to compile)
  • t/Token-error.t passes 28/28
  • make (full unit suite) BUILD SUCCESSFUL

Generated with Devin

Perl marks `dump` as a builtin that user code can override via `use subs`
or Exporter import. PerlOnJava's parser was unconditionally throwing
"Not implemented: operator: dump" before checking for a user override,
which broke any module that exports its own `dump` sub.

Concretely, Data::Dump declares `use subs qw(dump)` and exports `dump`
via Exporter. Inside Data/Dump.pm itself, calls like `dump(@_)` (line 82,
inside `sub dd`) hit the parser's hardcoded reject path and aborted
loading the module:

    Error:  Not implemented: operator: dump at .../Data/Dump.pm line 82,
            near "(@_"

This blocks any CPAN distribution that uses Data::Dump, e.g.
CPU::Z80::Assembler::Token (`jcpan -t CPU::Z80::Assembler::Token`).

Fix: add "dump" to ParserTables.OVERRIDABLE_OP so the existing
`use subs` / Exporter / CORE::GLOBAL override path in ParsePrimary is
consulted before CoreOperatorResolver raises the unimplemented-op error.
CORE_PROTOTYPES still maps `dump` → "", so explicit `CORE::dump()` keeps
hitting the unimplemented path; only user/imported `dump` subs now
resolve correctly.

Verified:
  - t/Token-new.t (CPU-Z80-Assembler-2.10) now passes 32/32
  - t/Token-error.t passes 28/28
  - `make` (full unit suite) BUILD SUCCESSFUL

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/dump-overridable branch from 13c618c to 342dad1 Compare April 29, 2026 08:40
@fglock fglock merged commit 3fb27ed into master Apr 29, 2026
2 checks passed
@fglock fglock deleted the fix/dump-overridable branch April 29, 2026 08:41
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