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

A andthen B orelse C leaks some internal Block #5783

Closed
p6rt opened this issue Nov 7, 2016 · 8 comments
Closed

A andthen B orelse C leaks some internal Block #5783

p6rt opened this issue Nov 7, 2016 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Nov 7, 2016

Migrated from rt.perl.org#130034 (status was 'resolved')

Searchable as RT130034$

@p6rt
Copy link
Author

p6rt commented Nov 7, 2016

From @LLFourn

15​:18 < llfourn_> m​: say (Str andthen .uc orelse "foo") # more golfed
15​:18 <+camelia> rakudo-moar 1c425f​: OUTPUT«-> ;; $_ is raw {
#`(Block|81391040) ... }␤»
15​:23 < llfourn_> m​: say (Str andthen .uc orelse "foo")("wee")
15​:23 <+camelia> rakudo-moar 1c425f​: OUTPUT«foo␤»

unless I totally missed what these are meant to do a Block is not what
should be returned from this expression.

@p6rt
Copy link
Author

p6rt commented Nov 9, 2016

From @zoffixznet

On Sun, 06 Nov 2016 20​:25​:50 -0800, lloyd.fourn@​gmail.com wrote​:

15​:18 < llfourn_> m​: say (Str andthen .uc orelse "foo") # more golfed
15​:18 <+camelia> rakudo-moar 1c425f​: OUTPUT«-> ;; $_ is raw {
#`(Block|81391040) ... }␤»
15​:23 < llfourn_> m​: say (Str andthen .uc orelse "foo")("wee")
15​:23 <+camelia> rakudo-moar 1c425f​: OUTPUT«foo␤»

unless I totally missed what these are meant to do a Block is not what
should be returned from this expression.

The issue is due to `andthen` (and `notandthen`) actually returning Empty instead of the advertized "first undefined value" and since Empty is a Slip, it causes an issue with `orelse`.

While the fix is trivial, it causes fallout with `with` operator and right now we're waiting for TimToady to chime in on how things should be done. IRC conversation​: https://irclog.perlgeek.de/perl6-dev/2016-11-09#i_13539174

@p6rt
Copy link
Author

p6rt commented Nov 9, 2016

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

@p6rt
Copy link
Author

p6rt commented Nov 9, 2016

From @LLFourn

Thanks for the update. As viki hinted at, isn't this a bug in itself
(andthen problems aside). Why does Empty as the first arg to orelse return
a block?

say (Empty orelse "foo")

-> ;; $_ is raw { #`(Block|140421623865904) ... }

Where as

say (Any orelse "foo")

returns the correct value.

On Thu, Nov 10, 2016 at 1​:51 AM Zoffix Znet via RT <
perl6-bugs-followup@​perl.org> wrote​:

On Sun, 06 Nov 2016 20​:25​:50 -0800, lloyd.fourn@​gmail.com wrote​:

15​:18 < llfourn_> m​: say (Str andthen .uc orelse "foo") # more golfed
15​:18 <+camelia> rakudo-moar 1c425f​: OUTPUT«-> ;; $_ is raw {
#`(Block|81391040) ... }␤»
15​:23 < llfourn_> m​: say (Str andthen .uc orelse "foo")("wee")
15​:23 <+camelia> rakudo-moar 1c425f​: OUTPUT«foo␤»

unless I totally missed what these are meant to do a Block is not what
should be returned from this expression.

The issue is due to `andthen` (and `notandthen`) actually returning Empty
instead of the advertized "first undefined value" and since Empty is a
Slip, it causes an issue with `orelse`.

While the fix is trivial, it causes fallout with `with` operator and right
now we're waiting for TimToady to chime in on how things should be done.
IRC conversation​:
https://irclog.perlgeek.de/perl6-dev/2016-11-09#i_13539174

@p6rt
Copy link
Author

p6rt commented Nov 10, 2016

From @zoffixznet

Empty isn't passed as an arg. It's just an empty slip that gets flattened, so `orelse` ends up with a single block as the arg (the thunked "foo"), which gets returned.

I don't know whether it should be evaluated first.

On Wed, 09 Nov 2016 15​:52​:35 -0800, lloyd.fourn@​gmail.com wrote​:

Thanks for the update. As viki hinted at, isn't this a bug in itself
(andthen problems aside). Why does Empty as the first arg to orelse return
a block?

say (Empty orelse "foo")

-> ;; $_ is raw { #`(Block|140421623865904) ... }

Where as

say (Any orelse "foo")

returns the correct value.

On Thu, Nov 10, 2016 at 1​:51 AM Zoffix Znet via RT <
perl6-bugs-followup@​perl.org> wrote​:

On Sun, 06 Nov 2016 20​:25​:50 -0800, lloyd.fourn@​gmail.com wrote​:

15​:18 < llfourn_> m​: say (Str andthen .uc orelse "foo") # more golfed
15​:18 <+camelia> rakudo-moar 1c425f​: OUTPUT«-> ;; $_ is raw {
#`(Block|81391040) ... }␤»
15​:23 < llfourn_> m​: say (Str andthen .uc orelse "foo")("wee")
15​:23 <+camelia> rakudo-moar 1c425f​: OUTPUT«foo␤»

unless I totally missed what these are meant to do a Block is not what
should be returned from this expression.

The issue is due to `andthen` (and `notandthen`) actually returning Empty
instead of the advertized "first undefined value" and since Empty is a
Slip, it causes an issue with `orelse`.

While the fix is trivial, it causes fallout with `with` operator and right
now we're waiting for TimToady to chime in on how things should be done.
IRC conversation​:
https://irclog.perlgeek.de/perl6-dev/2016-11-09#i_13539174

@p6rt
Copy link
Author

p6rt commented Nov 11, 2016

From @zoffixznet

Reply from TimToady​: https://irclog.perlgeek.de/perl6-dev/2016-11-11#i_13550043

I need to think a bit about this behaviour and maybe simply evaluating the thunk before returning it will fix the issues.

@p6rt
Copy link
Author

p6rt commented Dec 14, 2016

From @zoffixznet

On Sun, 06 Nov 2016 20​:25​:50 -0800, lloyd.fourn@​gmail.com wrote​:

15​:18 < llfourn_> m​: say (Str andthen .uc orelse "foo") # more golfed
15​:18 <+camelia> rakudo-moar 1c425f​: OUTPUT«-> ;; $_ is raw {
#`(Block|81391040) ... }␤»
15​:23 < llfourn_> m​: say (Str andthen .uc orelse "foo")("wee")
15​:23 <+camelia> rakudo-moar 1c425f​: OUTPUT«foo␤»

unless I totally missed what these are meant to do a Block is not what
should be returned from this expression.

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@287af6a37e00ad
Test​: Raku/roast@8d6a6397e7

@p6rt
Copy link
Author

p6rt commented Dec 14, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 14, 2016
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