Skip to content

Preserve undef lvalue aliases through goto wrappers #1915

Description

@fglock

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

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

  1. added
    bugSomething isn't working
    area:runtimeCore Perl runtime semantics
    area:cpan-portCPAN compatibility ports and providers
    on Oct 28, 2026
  2. fglock commented on Oct 28, 2026

    @fglock
    OwnerAuthor

    State: released
    Agent/session: Codex root, 20261028-subquote-lvalue
    Scope: #1915, preserve writable undef-valued lvalue returns through goto &sub on 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 make and make check-links passed. The focused regression passes system Perl and both PerlOnJava backends; the unfixed parent failed both backends. Sub::Quote 2.006009 passed all 15 files/6,641 tests on JVM and interpreter.
    Blocked by: none.
    Next: none; resolution delivered.

  3. added a commit that references this issue on Oct 28, 2026
    fab237f
  4. added a commit that references this issue on Oct 28, 2026
    a5bb374
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cpan-portCPAN compatibility ports and providersarea:runtimeCore Perl runtime semanticsbugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions