Dynamic Moose constructors pass string \\@ instead of HashRef

Open
#1,393 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
java, perl
Domain
backend, compilers

Research direction

Start by reproducing the failure in t/Spreadsheet/Reader/01-format_interface.t, t/Spreadsheet/Reader/Format/02-fmt_default.t, and t/Spreadsheet/Reader/Format/03-parse_excel_fmt_string.t, comparing the JVM and interpreter backends. Trace the shared dynamic-evaluation, argument-construction, Moose integration, or reference-representation path used by MooseX::ShortCut::BuildInstance. Done means a HashRef receives a real reference and permanent regression coverage passes on both backends.

Written by the indexing model from the issue text.

Description

area:backend area:cpan-port area:runtime bug

Summary

Spreadsheet::Reader::Format v0.6.5 fails on PerlOnJava when its tests use
MooseX::ShortCut::BuildInstance to dynamically construct classes with roles
and typed attributes. PerlOnJava passes the literal string "\\@" to a
HashRef attribute instead of the expected hash reference.

The failure reproduces on both the JVM backend and the interpreter backend.

CPAN evidence

  • Distribution: Spreadsheet-Reader-Format v0.6.5
  • CPAN run: 20260915-125610-17469
  • Failure record: FAIL Spreadsheet::Reader::Format Spreadsheet::Reader::Format
  • Upstream test suite: 4 test files, 1,411 tests
  • System Perl result: all 1,411 tests pass
  • PerlOnJava result: 3 of 4 test files fail after the test command starts
  • Target distribution: pure Perl; no XS or native-library prerequisite

The archived CPAN run reached the target test command but exceeded the
tester’s 120-second soft limit without producing output. A bounded direct run
completed after approximately 163 seconds and produced the deterministic
failures below, so this is not classified as a timeout-only failure.

Observed failure

The first failing test reports:

Attribute (defined_excel_translations) does not pass the type constraint:
Value "\\@" did not pass type constraint "HashRef"

The error originates while MooseX::ShortCut::BuildInstance constructs a
temporary class and applies the Spreadsheet::Reader::Format roles. The
subsequent test-harness error is:

Can't call method "find_attribute_by_name" on an undefined value

The same defined_excel_translations/"\\@" failure occurs in:

  • t/Spreadsheet/Reader/01-format_interface.t
  • t/Spreadsheet/Reader/Format/02-fmt_default.t
  • t/Spreadsheet/Reader/Format/03-parse_excel_fmt_string.t

t/Spreadsheet/Reader/Format/01-types.t passes.

Minimal reproducer shape

The upstream tests call build_instance with dynamically selected
superclasses and roles, for example:

my $test_instance = build_instance(
    package => 'FormatInterfaceTest',
    superclasses => [ 'Spreadsheet::Reader::Format::FmtDefault' ],
    add_roles_in_sequence => [
        'Spreadsheet::Reader::Format::ParseExcelFormatStrings',
        'Spreadsheet::Reader::Format',
    ],
    _alt_epoch_year => 1904,
);

The generated class contains a defined_excel_translations attribute typed
as HashRef. Under standard Perl, construction succeeds. Under PerlOnJava,
the constructor receives "\\@" for that attribute and rejects it before the
test assertions can run.

Backend scope

The failure is reproducible on both backends:

  • JVM backend: the three tests fail with the typed-attribute error.
  • Interpreter backend: the same typed-attribute error appears in the first
    two failing tests before the bounded run ends.

This makes a backend-specific implementation defect unlikely; the shared
dynamic-evaluation, argument construction, Moose integration, or reference
representation path is the likely ownership area.

Impact

This blocks a pure-Perl spreadsheet formatting module and hides 1,390 of the
1,411 upstream assertions behind constructor failures. More broadly, the
same defect may affect CPAN modules that use Moose roles, dynamically
generated classes, typed attributes, and MooseX::ShortCut::BuildInstance.
Applications may see constructor failures or invalid typed values rather than
the expected object instances.

Expected fix

Preserve Perl-compatible reference values and constructor arguments when
dynamic classes are generated and instantiated through eval-constructed
code. In particular, a HashRef attribute must receive an actual hash
reference, not the string "\\@".

Add permanent project-owned regression coverage, validated first with system
Perl, covering:

  1. A dynamically generated Moose class with a HashRef attribute.
  2. Role application through add_roles_in_sequence.
  3. Constructor invocation through MooseX::ShortCut::BuildInstance.
  4. JVM/interpreter parity.

Deduplication

Existing issues were searched using the distribution name, stable error text,
MooseX::ShortCut::BuildInstance, defined_excel_translations, and the
HashRef/reference symptom.

  • No existing issue directly covers this dynamic Moose constructor failure.
  • #1264 concerns missing autobox XS compile-time dispatch and is unrelated.
  • #1343 concerns foreach hash-reference aliasing and is unrelated.

This report is therefore not a duplicate.

Dominant language
Perl
Stars
64
Forks
6
Avg merge
5h 25m
Merged PRs (30d)
157

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fglock/PerlOnJava

All issues in fglock/PerlOnJava

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.