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 return empty typed List #948
Comments
From @skidsThe following work as expected: my Num List sub f () { return ("A") }; The following dies with "Type check failed on return value" my Num List sub f () { return () }; And as an aside, type checks seem to be skipped for implicit returns: my Num List sub f () { ("A") }; f.say; # says "A" |
From @jnthnOn Sat Apr 25 09:23:43 2009, bri@abrij.org wrote:
First, all of these should be compile time failures, since only one type I think what you really wanted to write was: my List of Num sub f() { ... } However, that's not quite supported yet in Rakudo (it will be, just not my Positional of Num sub f() { ... } If you're going to write one of these, you need to return an explicitly my Positional of Num sub f() { return (1,2,3) }; f() And you need to write this: my Positional of Num sub f() { my Num @l = 1,2,3; return @l; }; f() Subtyping works too, so you can write: my Positional of Num sub f() { my Int @l = 1,2,3; return @l; }; f() But in general, if you're going to be dealing with parametric type
Yes, that was a problem. I have fixed that too now, in the same push. Thanks, Jonathan |
The RT System itself - Status changed from 'new' to 'open' |
From @jnthnOn Fri Jun 05 07:29:16 2009, jnthn@jnthn.net wrote:
Oops, meant to Cc the above explanation to the list the first time. In addition, finished fixing up completely (as far as I know it needs Thanks, Jonathan |
@jnthn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#65128 (status was 'resolved')
Searchable as RT65128$
The text was updated successfully, but these errors were encountered: