fix(parser): make dump an overridable core operator#612
Merged
Conversation
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>
13c618c to
342dad1
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
Make Perl's
dumpbuiltin overridable so modules that export their owndumpsub (notablyData::Dump) can be loaded.PerlOnJava's parser was unconditionally throwing
Not implemented: operator: dumpbefore checking for a user override, which broke any module that imports adumpsub. Concretely,Data::Dumpdeclaresuse subs qw(dump)and exportsdumpvia Exporter; insideData/Dump.pmitself calls likedump(@_)(line 82, insub dd) hit the parser's hardcoded reject path:This blocks any CPAN distribution that uses
Data::Dump, which is how I found it:jcpan -t CPU::Z80::Assembler::Tokenfailed at theuse Data::Dump;line.Fix
Add
"dump"toParserTables.OVERRIDABLE_OP. The existing override path inParsePrimary(which already handlesuse subs, Exporter typeglob assignment, andCORE::GLOBAL::*) is now consulted beforeCoreOperatorResolverraises the unimplemented-op error.CORE_PROTOTYPESstill mapsdump→"", so an explicitCORE::dump()keeps hitting the unimplemented path — only user/importeddumpsubs resolve to the imported sub.Test plan
t/Token-new.tfromCPU-Z80-Assembler-2.10passes 32/32 (previously aborted atuse CPU::Z80::Assembler::Tokenbecause Data::Dump failed to compile)t/Token-error.tpasses 28/28make(full unit suite) BUILD SUCCESSFULGenerated with Devin