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

Failure bound to variable, as result of if statement, sinks and throws #4460

Closed
p6rt opened this issue Aug 8, 2015 · 6 comments
Closed

Failure bound to variable, as result of if statement, sinks and throws #4460

p6rt opened this issue Aug 8, 2015 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Aug 8, 2015

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

Searchable as RT125769$

@p6rt
Copy link
Author

p6rt commented Aug 8, 2015

From @skids

A newly created Failure can be prevented from sinking by assigning
it to a variable. Binding it to a variable also protects it from
being immediately sunk. However, when the latter happens as the last
statement in an if { ... }, the exception is sunk and thrown.

Expected behavior​: The "bar" failure below should not throw.

$ cat /tmp/foo.pm6
sub a {
  if (1) {
  my $f = Failure.new("foo");
  }
  return 1;
}
my $a = a();

sub b {
  if (1) {
  my $f := Failure.new("bar");
  }
  return 1;
}
my $b = b();
42.say

$ perl6 /tmp/foo.pm6
bar
  in sub b at /tmp/foo.pm6​:10
  in block <unit> at /tmp/foo.pm6​:15

Actually thrown at​:
  in sub b at /tmp/foo.pm6​:10
  in block <unit> at /tmp/foo.pm6​:15

@p6rt
Copy link
Author

p6rt commented Dec 17, 2015

From @TimToady

Minimal test case​:

{ my $f := Failure.new("bar"); }

This doesn't seem to be sink related, at least not directly. It seems more to be related to the difference between storing things in a local vs in a lexical, and how those are treated on statement or return boundaries.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 17, 2015

From @TimToady

Minimal test case​:

{ my $f := Failure.new("bar"); }

This doesn't seem to be sink related, at least not directly. It seems more to be related to the difference between storing things in a local vs in a lexical, and how those are treated on statement or return boundaries.

@p6rt
Copy link
Author

p6rt commented Dec 19, 2015

From @TimToady

Fixed in 091ee7507464595e7712f4ae911d95d467e5281b

Tests in 8b97aa4f6191affdd91da78607eca4ae6dc73b11

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 19, 2015

From @TimToady

Fixed in 091ee7507464595e7712f4ae911d95d467e5281b

Tests in 8b97aa4f6191affdd91da78607eca4ae6dc73b11

@p6rt
Copy link
Author

p6rt commented Dec 19, 2015

@TimToady - Status changed from 'new' to 'resolved'

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