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

LEAVE trap (my $x = …; LEAVE $x.foo) #1539

Closed
AlexDaniel opened this issue Sep 5, 2017 · 2 comments
Closed

LEAVE trap (my $x = …; LEAVE $x.foo) #1539

AlexDaniel opened this issue Sep 5, 2017 · 2 comments
Labels
docs Documentation issue (primary issue type) trap

Comments

@AlexDaniel
Copy link
Member

AlexDaniel commented Sep 5, 2017

It is a fairly common mistake.

Basically, code like this is wrong:

my $x = 42;
LEAVE say $x.Int; # ← WRONG; assumes that $x is not Nil

This is true even if $x is defined at the start of the block.

For example:

sub foo($ where abc) {
    my $x = 42;
    LEAVE say $x.Int; # ← WRONG; assumes that $x is not Nil
}
say foo hello; # OUTPUT: «No such method 'Int' for invocant of type 'Any'␤»
@AlexDaniel AlexDaniel added the docs Documentation issue (primary issue type) label Sep 5, 2017
@smls
Copy link
Contributor

smls commented Sep 8, 2017

Are you sure that this is not a Rakudo bug?
Why does the phaser run even though the subroutine's signature didn't match?

@AlexDaniel
Copy link
Member Author

It could be, but generally assuming that LEAVE $foo.bar will work is a common trap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation issue (primary issue type) trap
Projects
None yet
Development

No branches or pull requests

2 participants