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
Comments
From @FROGGSFROGGS m: multi foo(Int) is cached { say 'Int' }; multi foo(Str) { say 'Str' }; foo 1; foo 1; foo 'a'; foo 'a' |
From @hoelzroThe attached file contains the following code:
...which, when run, results in the following error message:
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. |
use experimental :cached;
multi fib(0) { 0 }
multi fib(1) { 1 }
multi fib(Int $n where * >= 0 ) is cached { dd; fib($n - 2) + fib($n - 1) }
say fib(18);
say fib(18); results in:
So the second time we do Closing now. |
Migrated from rt.perl.org#122899 (status was 'new')
Searchable as RT122899$
The text was updated successfully, but these errors were encountered: