Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return in block doesn't see outside return signature #6047

Open
p6rt opened this issue Feb 2, 2017 · 3 comments
Open

Return in block doesn't see outside return signature #6047

p6rt opened this issue Feb 2, 2017 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Feb 2, 2017

Migrated from rt.perl.org#130706 (status was 'open')

Searchable as RT130706$

@p6rt
Copy link
Author

p6rt commented Feb 2, 2017

From @lizmat

<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

@p6rt
Copy link
Author

p6rt commented Feb 2, 2017

From @zoffixznet

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-archive.perl.org/perl6/Ticket/Display.html?id=129874#ticket-history

@p6rt
Copy link
Author

p6rt commented Feb 2, 2017

The RT System itself - Status changed from 'new' to 'open'

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

No branches or pull requests

1 participant