Skip to content

fix: improve Croak diagnostic parity - #1423

Open
fglock wants to merge 111 commits into
masterfrom
wip/croak-progress-20260917-230522
Open

fglock wants to merge 111 commits into
masterfrom
wip/croak-progress-20260917-230522

Conversation

@fglock

@fglock fglock commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • improve Perl-compatible compiler diagnostics exercised by perl5_t/t/lib/croak.t
  • retain source locations for interpolated heredoc failures and preserve quoted delimiters
  • diagnose invalid typeglob foreach iterators as missing scalar loop variables
  • add focused system-Perl, JVM, and interpreter regression coverage

Validation

  • prove src/test/resources/unit/missing_loop_variable_diagnostic.t
  • timeout 120 ./jperl src/test/resources/unit/missing_loop_variable_diagnostic.t
  • timeout 120 ./jperl --interpreter src/test/resources/unit/missing_loop_variable_diagnostic.t
  • nice -n 20 timeout 1200 make — passed
  • timeout 300 ../../jperl lib/croak.t from perl5_t/t — failures reduced from 50 to 49

@fglock
fglock force-pushed the wip/croak-progress-20260917-230522 branch 2 times, most recently from 0d19c6d to 3777be7 Compare September 20, 2026 09:15
fglock and others added 28 commits September 20, 2026 12:10
Reject ${#}, ${*}, and their symbolic braced spellings with the Perl 5.30
compatibility diagnostic instead of accepting them or crashing the parser.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Reject conditional expressions and do blocks in lexical declarations with
Perl-compatible EOF diagnostics, including sources that end in a newline.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject conflicting use VERSION declarations in the same lexical scope with
Perl-compatible diagnostics.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Diagnose non-array bareword arguments in the parser with the Perl-compatible
array-argument error.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject a comma immediately after join and report its source location from
the operator token, matching Perl's arity diagnostic and context.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Use the declaration token when reporting an invalid global-only lexical,
so the diagnostic identifies the declaration rather than its trailing token.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Diagnose bareword arguments to keys, values, and each as constant items during
parsing, with Perl-compatible argument errors.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Point state declarations used in list assignment at the closing parenthesis,
matching Perl's diagnostic context.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Keep eval STRING filenames independent for each calling source and reject
Unicode punctuation in lexical declarations.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject invalid delete and exists arguments during parsing with Perl-compatible
messages and source locations.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Report forbidden control flow from defer and finally blocks with Perl's
line-only diagnostic format on both execution backends.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject unary callback expressions for feature-gated all and any with a
Perl-compatible syntax location. Add regression coverage on both backends.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Report Perl's specific return diagnostic before map parsing, while preserving
valid return statement modifiers. Add permanent regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Fetch tied class-name scalars before validating them and reject non-stringified
references with Perl's expected diagnostic. Add regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Track given parsing scope so switch statements report Perl-compatible
topicalizer diagnostics outside a given block. Add regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Validate %SIG names at assignment time and report Perl's hook diagnostic.
Add regression coverage for unknown and known hook assignments.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject defined assignments to `${^ENCODING}` while retaining Perl-compatible
undef assignment and localization behavior. Add permanent regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Match Perl's object-versus-typeglob diagnostic for class instances.
Add permanent regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject numeric and string bitwise compound assignments to aggregates with
Perl-compatible diagnostics. Add permanent regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject aggregate arguments to lvalue substr and vec with Perl-compatible
diagnostics, including parenthesized forms. Add permanent regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Preserve Perl's hash, lexical hash, and typeglob diagnostics for invalid
push, pop, shift, and unshift operands, including every direct error in one
compilation.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Match Perl's undefined hash-reference diagnostic when an aggregate value is
used as a hash reference.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Retain the opening array or hash delimiter while reporting a mismatched closing
delimiter, matching Perl's syntax context. Add a nested compiler regression
test covering the core croak case.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Evaluate CORE::dump labels and report the Perl-compatible missing-label error
instead of leaving the label expression as a parser error.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Distinguish undefined scalar codereferences from invalid non-code values so
direct and tied calls retain Perl-compatible diagnostics.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Preserve lexical handle names so open and opendir report Perl-compatible
diagnostics when an active handle has the opposite kind.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Use Perl-compatible errors for sysread and syswrite on :utf8 handles.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Reject non-reference and mismatched reference iterator values without
autovivification, matching Perl's diagnostics and source locations.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
fglock and others added 27 commits September 20, 2026 12:10
Permit a literal all/any block inside the legal invocation parentheses while
continuing to reject unary callback forms.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Defer invalid local-through-reference failures to runtime on both backends so
eval can catch the normal Perl error.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Preserve Perl's unary-plus parse disambiguation when validating and
compiling nested exists and delete element targets.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Capture the parser's logical source location for JVM runtime local-reference
errors so #line directives remain accurate.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Treat a single parenthesized state target as the scalar lvalue required by
logical assignment, retaining its persistent identity on both execution
backends. Add system-Perl-validated regression coverage.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Match Perl's visible \\0 spelling for embedded NUL bytes in invalid %SIG
hook names on both execution backends.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Route malformed OS signal assignments through Perl's signal warning path and
avoid vivifying invalid %SIG slots, while retaining hook diagnostics.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Resolve a dynamic goto target before applying the foreach entry guard, so a
jump within the active loop body retains its initialized iterator state.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Match Perl's initial $? value so code does not treat an uninitialized status
as a failed child process before any child has run.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Reuse predeclared label targets in active scopes so duplicate labels resolve
to the nearest lexical block instead of a globally nearby source token.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Distinguish missing from explicitly undefined :param arguments and apply
defined and truthy field defaults with their respective Perl semantics.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Keep skipped state lexicals distinct from prior temporary registers and
evaluate an initialized state declaration's RHS only on first entry.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Generate constructor presence checks for required :param fields while
preserving explicitly supplied undef values.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Permit internal do-block labels in generated field initializers and use the
external bare :param spelling for required constructor validation.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Carry a localized false $^W with non-local loop-control markers so Perl's
subroutine-exit warning remains suppressed after scope unwinding.  Unknown
%SIG signal names now warn while retaining their handler slots, matching Perl.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Ensure pending static gotos use the active scope target when folding has
cloned the original block, preventing an unresolved jump from returning to
bytecode PC 0.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Use the bundled Perl Unicode XID additions where ICU lags, without admitting
the compatibility characters Java classifies as identifiers.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Only validate a typed lexical against %Type::FIELDS when that hash slot
actually exists; a forward-declared FIELDS sub is not a legacy fields map.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Load the enclosing class before validating a nested class's :isa parent,
matching Perl's loading of A while compiling A::B.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Correct named-sequence detection in transliteration and preserve foreach
goto diagnostics when eval-local labels shadow later outer labels across
the JVM and interpreter backends.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <noreply@openai.com>
Compile scalar-context keys %hash directly to the hash count so repeated
empty-hash queries do not allocate a transient RuntimeArray.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Assign the foreach array-dereference opcode its unused value after master
introduced a conflicting opcode assignment.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock
fglock force-pushed the wip/croak-progress-20260917-230522 branch from d143c6f to 0bdd77e Compare September 20, 2026 10:20
fglock and others added 2 commits September 20, 2026 14:32
Clear the thread-local last-readline handle before each embedded top-level
program so a prior unit test cannot change indirect readline parsing in the
next program. Add tracked nested-class fixtures for the unit corpus.

Generated with [Codex](https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
Dispatch losslessly decoded jperl arguments directly to Main before applying
the delayed-expansion restriction needed only by real batch targets. This
keeps multiline -e diagnostics containing literal exclamation marks intact.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
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