Skip Menu |
Report information
Id: 130706
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: elizabeth <liz [at] dijkmat.nl>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
Subject: Return in block doesn't see outside return signature
To: rakudobug [...] perl.org
Date: Thu, 2 Feb 2017 22:35:39 +0100
Download (untitled) / with headers
text/plain 1.2k
<lizmat> m: sub a(--> 42) { { return } }; dd a # expected 42 <+camelia> rakudo-moar f2894d: OUTPUT«Nil␤» <lizmat> jnthn: am I wrong in expecting that? ^^^ <jnthn> What were you expecting? <jnthn> Looks right to me. <jnthn> m: sub a(--> 42) { return }; dd a <+camelia> rakudo-moar f2894d: OUTPUT«42␤» <jnthn> How does that one work? <jnthn> I thought the --> was just for the fall-off-the-end though... <lizmat> jnthn: apparently not ? <lizmat> m: sub a(--> 42) { return 666 } <+camelia> rakudo-moar f2894d: OUTPUT«===SORRY!=== Error while compiling <tmp>␤No return arguments allowed when return value 42 is already specified in the signature␤at <tmp>:1␤------> sub a(--> 42) { return 666 ⏏}␤» <lizmat> jnthn: so I guess a bare return is sorta expected in this case <jnthn> m: sub a(--> 42) { if 1 { return 666 } } <+camelia> rakudo-moar f2894d: ( no output ) <jnthn> Fail <jnthn> m: sub a(--> 42) { if 1 { return } }; say a <+camelia> rakudo-moar f2894d: OUTPUT«Nil␤» <jnthn> That's a pretty bad discrepancy <jnthn> m: sub a(--> 42) { return }; say a <+camelia> rakudo-moar f2894d: OUTPUT«42␤» jnthn wonders how that works :) <lizmat> rakudobug material ? <jnthn> Surely <jnthn> I didn't even know we had that feature :P
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 306b
No idea if there's any relation between the two, but there's also this ticket where a return type constraint set to Nil on a sub affects interpolation of a code block in a string inside that sub; almost as if the constraint propagated to it: https://rt.perl.org/Ticket/Display.html?id=129874#ticket-history


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org