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 caught exception still exits a sub ? #4809

Closed
p6rt opened this issue Dec 3, 2015 · 4 comments
Closed

A caught exception still exits a sub ? #4809

p6rt opened this issue Dec 3, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Dec 3, 2015

Migrated from rt.perl.org#126789 (status was 'rejected')

Searchable as RT126789$

@p6rt
Copy link
Author

p6rt commented Dec 3, 2015

From @lizmat

[01​:02​:33] <lizmat> m​: sub a($a) { $a(); CATCH { default { say "default" } }; 42 }; say a( -> { die } ) # shorter version
[01​:02​:33] <camelia> rakudo-moar f0a96d​: OUTPUT«default␤Nil␤»
[01​:02​:43] <lizmat> I sorta expect this to say 42
[01​:02​:48] <lizmat> am I wrong ?

This is the cause of the failure in t/spec/S17-scheduler/at.t

@p6rt
Copy link
Author

p6rt commented Dec 4, 2015

From @TimToady

The default of die is to, er, die. You can resume after a die, but only if you do so explicitly, in which case you are responsible for overriding the expectations of whoever wrote the die and likely did not expect it to return.

p6 'sub a($a) { $a(); CATCH { default { say "default"; .resume } }; 42 }; say a( -> { die } )'
default
42

Here's the problem with that​:

p6 'sub a($a) { $a(); CATCH { default { say "default"; .resume } }; 42 }; say a( -&gt; { die unless $*INVARIANT; } )'default
42

Okay so far, but suppose we violate the invariant...

p6 'sub a($a) { $a(); CATCH { default { say "default"; .resume } }; 42 }; say a( -&gt; { die unless $*INVARIANT; say "assume $*INVARIANT" } )'
default
default
default
This exception is not resumable
  in block at -e​:1
  in block <unit> at -e​:1

So resuming is never going to be the default for die. (That's why we have warn, after all.)

@p6rt
Copy link
Author

p6rt commented Dec 4, 2015

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

@p6rt p6rt closed this as completed Dec 4, 2015
@p6rt
Copy link
Author

p6rt commented Dec 4, 2015

@TimToady - Status changed from 'open' to 'rejected'

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