You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
➜ sub f (::T --> T) { T.new }
➜ f Int;
Died with X::TypeCheck::Return
in sub f at [...]
The type alias T works just fine in the rest of the subroutine signature
and body; just not inside the return type constraint, and also not in
the return type constraint of any nested subroutine:
➜ sub f (::T) { sub g (--> T) { T.new } }
➜ say f(Int)();
Died with X::TypeCheck::Return
in sub g at [...]
The alternative `returns T` and `of T` syntaxes suffer from the same
problem.
$ ./rakudo-m -e 'sub f (::T --> T) { T.new }; say(f Int)'
0
$ ./rakudo-m -e 'sub f (::T) { sub g (--> T) { T.new } }; say f(Int)()'
0
And the return type constraint also seems to apply:
$ ./rakudo-m -e 'sub f (::T --> T) { 42 }; say(f Int)'
42
$ ./rakudo-m -e 'sub f (::T --> T) { "foo" }; say(f Int)'
Type check failed for return value; expected Int but got Str ("foo")
in sub f at -e line 1
in block <unit> at -e line 1
Migrated from rt.perl.org#131948 (status was 'new')
Searchable as RT131948$
The text was updated successfully, but these errors were encountered: