Repository navigation
Preserve undef lvalue aliases through goto wrappers #1915
Description
Summary
Sub::Quote 2.006009 fails on PerlOnJava when Sub::Defer creates an attributed :lvalue wrapper. The wrapper uses goto &$undeferred to forward a call to a deferred subroutine. When the deferred sub returns a writable lexical slot whose current value is undef, PerlOnJava rejects the return as though it were an invalid empty/undef lvalue return.
The affected CPAN run is 20261028-144340-47138, failure row Sub::Defer from Sub::Quote. The three affected test programs are t/sub-defer-no-subname.t, t/sub-defer.t, and t/sub-quote.t; each reaches all its assertions before process exit 255 with Can't return undef from lvalue subroutine at Sub/Defer.pm line 163.
Reproducer
my $slot;
sub target :lvalue { $slot }
sub wrapper :lvalue { goto &target }
wrapper() = 'assigned';System Perl accepts the assignment and updates $slot. PerlOnJava rejects it on both JVM and interpreter backends. The behavior is distinct from a genuinely invalid empty scalar lvalue return, which must continue to report Can't return undef from lvalue subroutine.
Evidence
Sub-Quote2.006009 contains pure Perl; no XS/native dependency is involved.- System Perl 5.34.1: complete focused upstream suite passes (15 files, 6,546 tests).
- PerlOnJava parent
c7c805b7aca9bb1ce5effb5f151ccea5caaa48a8: the focused reproducer fails on both backends. - Environment: macOS arm64, OpenJDK 24.0.2.
- Prior lvalue-subroutine compatibility work in fix: complete lvalue subroutine return compatibility #1479 added validation for genuine invalid undef returns; this report concerns forwarding a writable undef slot through
goto. - The related thread-identity issue Sub::Quote deferred subs lose identity across threads #1420 was fixed separately by fix: preserve fieldhash and deferred sub identity in threads #1761 and is not part of this behavior.
Expected behavior
A :lvalue subroutine using goto &target must preserve the target's writable scalar cell, including when that cell currently contains undef, on both execution backends. Invalid empty and readonly lvalue returns must remain rejected.
Activity
fglock commentedon Oct 28, 2026
State: released
Agent/session: Codex root, 20261028-subquote-lvalue
Scope: #1915, preserve writable undef-valued lvalue returns through
goto &subon JVM and interpreter; retain invalid empty-return diagnostics.Work: PR #1917 merged to master as
fab237f39ba5c3c21d56f3a19ddad7ca9087f923.Checkpoint: 2026-10-28; PR merged and issue #1915 closed. The separate #1420 issue was already resolved by merged PR #1761.
Evidence: required GitHub Ubuntu and Windows checks passed; final
nice -n 19 makeandmake check-linkspassed. The focused regression passes system Perl and both PerlOnJava backends; the unfixed parent failed both backends.Sub::Quote2.006009 passed all 15 files/6,641 tests on JVM and interpreter.Blocked by: none.
Next: none; resolution delivered.
fix: preserve lvalue returns through goto markers
docs: remove resolved issue from project shortlist