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

Cannot apply trait 'is cached' on multi candidate #3540

Open
p6rt opened this issue Oct 4, 2014 · 3 comments
Open

Cannot apply trait 'is cached' on multi candidate #3540

p6rt opened this issue Oct 4, 2014 · 3 comments

Comments

@p6rt
Copy link

@p6rt p6rt commented Oct 4, 2014

Migrated from rt.perl.org#122899 (status was 'new')

Searchable as RT122899$

@p6rt
Copy link
Author

@p6rt p6rt commented Oct 4, 2014

From @FROGGS

FROGGS m​: multi foo(Int) is cached { say 'Int' }; multi foo(Str) { say 'Str' }; foo 1; foo 1; foo 'a'; foo 'a'
camelia rakudo-moar b3331e​: OUTPUT«Cannot invoke object with invocation handler in this context␤ in sub foo at /tmp/zWM01_TzeB​:1␤ in block <unit> at /tmp/zWM01_TzeB​:1␤␤»
FROGGS :/
FROGGS I feared that
lizmat that's odd, the wrap should only be applied to the first
FROGGS m​: multi foo(Int) is cached { say 'Int' }; foo 1; foo 1;
camelia rakudo-moar b3331e​: OUTPUT«Cannot invoke object with invocation handler in this context␤ in sub foo at /tmp/EpBFnacF6n​:1␤ in block <unit> at /tmp/EpBFnacF6n​:1␤␤»
lizmat that's worthy of a rakudobug
FROGGS m​: sub foo(Int) is cached { say 'Int' }; foo 1; foo 1;
camelia rakudo-moar b3331e​: OUTPUT«Int␤»
FROGGS yeah

@p6rt
Copy link
Author

@p6rt p6rt commented May 29, 2015

From @hoelzro

The attached file contains the following code​:

multi fib(0) { 0 }
multi fib(1) { 1 }
multi fib(Int $n where * >= 0 ) is cached { fib($n - 2) + fib($n - 1) }

say fib(18);

...which, when run, results in the following error message​:

Cannot invoke object with invocation handler in this context
in block <unit> at test.p6​:5

The proper way to fix this code is declare proto fib(Int $) is cached { * }, but that's not obvious from the error message. I'm not sure if this happens with other Routine traits, but I wouldn't be surprised.

@p6rt
Copy link
Author

@p6rt p6rt commented May 29, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.