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
Implement a way to propagate exceptions in Junctions #6181
Comments
From @briandfoyConsider this junction which you probably shouldn't make but you know any( 5, 'flarg' ) == 5 Despite having an element that satisfies the condition, it blows up > any(5, "flarg") == 5 But, it should't matter that what happens with any other parts of the any( True, Failure ); But, I don't think it should evaluate to another junction at all. The |
From @briandfoyThe person who sent me this example (and who wishes to remain anonymous), wants me to note that I didn't come up with this example. Specifically, "you should note that this bug report was generated who has never used perl6 in any form". |
From @zoffixznetOn Fri, 07 Apr 2017 10:08:54 -0700, comdog wrote:
FWIW the explosion doesn't involve Junctions: "flarg".Numeric is a Failure, but then an attempt is made to use that failure to evaluate the `==` op, at which point that Failure's exception is actually thrown: $ perl6 -e 'dd WHAT "flarg".Numeric' |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetAnd if you just give a Failure into a Junction it doesn't explode it and propagates it: m: say so any("flarg",42)».Numeric Wonder if there's a way to make it handle exceptions too somehow. A sort of Junctionized `try` block |
From @AlexDanielCorrect. This is not a bug for sure, but I wonder if there's anything we can improve. I created a doc ticket here: Raku/doc#1271 Now I wonder, can the backtrace mention that this was inside a junction? This will resolve the confusion, I think. On 2017-04-07 10:15:55, cpan@zoffix.com wrote:
|
From @LLFournThe correct way to do this is any(5,"flarg") ~~ 5. ~~ is very tolerant. I I tried to think of how I could use a particular comparison operator with a any(5,"flarg") ~~ { try $_ == 5 } I guess bare blocks don't autothread because $_ is Mu, but I would have The best I can do is the rather hairy: say so any(5,"flarg") ~~ -> Any $_ { try $_ == 5 } which also throws some "useless use of" exception for some reason :\ LL And if you just give a Failure into a Junction it doesn't explode it and m: say so any("flarg",42)».Numeric m: say sub ($_) { .^name }( +any("flarg",42) ) Wonder if there's a way to make it handle exceptions too somehow. A sort of |
From @zoffixznetOn Fri, 07 Apr 2017 19:09:55 -0700, lloyd.fourn@gmail.com wrote:
Well, they do. The exception gets thrown. It just aborts all of the results. In a superimposition of multiple universes calculating $foo == 42, a crash in one universe crashes all of them :| Would be interesting to see a Junctioned result in $! though :)
Yes. Please report anything that explodes in smartmatch. We recentlish fixed Str ~~ Numeric smartmatch exploding, so actually anyone on latest Rakudo Star would get an explosion in `"foo" ~~ 42`
That's correct. Only subs and methods default to Any. Variables, attributes, and block's params default to Mu type constraint. Asking for a `Mu` is a way to avoid Junctional autothreading in routines. You'll notice a Junction is a Mu, but unlike most Perl 6 classes, is not an Any.
Changing it breaks 5 stresstests. We also smartmatch in `when` blocks and `where` constraints, so the impact would be far-reaching. Making ACCEPTS not accept a Mu breaks this code for example; it no longer prints the string: $_ = 42|42; when *.so { say "there"} |
From @briandfoyOn Fri, 07 Apr 2017 19:09:55 -0700, lloyd.fourn@gmail.com wrote:
Well, for == you can do that. For other comparison operators, such as >, you can't. The point wasn't the particular test but rather the behavior when something wants to fail hard. |
From @LLFournThanks for doing that experiment. Not sure why the code breaks. But yeah on LL On Sat, Apr 8, 2017 at 12:58 PM Zoffix Znet via RT <
Would be interesting to see a Junctioned result in $! though :)
|
From @zoffixznetOn Fri, 07 Apr 2017 10:08:54 -0700, comdog wrote:
Thank you for the report. However, I'm going to reject the ticket. As previous replies mentioned, there's no problem with Failures in a Junctions, I'm unsure if one of the suggestions was to catch such exceptions and turn Some of the other suggestions were to make `try` Junctionable and stuff Lastly, I added a 'Failures and Exceptions' section to Junction docs[^1] that [1] Raku/doc@7628708 |
@zoffixznet - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#131118 (status was 'rejected')
Searchable as RT131118$
The text was updated successfully, but these errors were encountered: