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
The first one says it expected Int but got Str, when in reality the type constraint is Any-to-Int:D coercer.
The second one talks about Int methods, but I ain't calling any. IMO the coercer should catch such errors when calling the method and report them as type check failure instead.
18:34 Zoffix m: sub (Int:D()) {}( Str )
18:34 camelia rakudo-moar fb7dd8: OUTPUT: «Type check failed in binding to parameter '<anon>'; expected Int but got Str (Str) in sub at <tmp> line 1 in block <unit> at <tmp> line 1»
18:34 Zoffix m: sub (Int()) {}( Str )
18:34 camelia rakudo-moar fb7dd8: OUTPUT: «Invocant of method 'Int' must be an object instance of type 'Str', not a type object of type 'Str'. Did you forget a '.new'? in sub at <tmp> line 1 in block <unit> at <tmp> line 1»
p6rt
added
the
LTA
Less Than Awesome; typically an error message that could be better
label
Jan 5, 2020
$ ./rakudo-m -e 'sub (Int:D()) {}( Str )'
Parameter '<anon>' of routine '<anon>' must be an object instance of
type 'Int:D(Any)', not a type object of type 'Str'. Did you forget a
'.new'?
in sub at -e line 1
in block <unit> at -e line 1
$ ./rakudo-m -e 'sub (Int()) {}( Str )'
Cannot create an Int from a 'Str' type object
in sub at -e line 1
in block <unit> at -e line 1
The second evaluation fails with X::AdHoc. But in general the new behavior looks sensible to me.
Migrated from rt.perl.org#131413 (status was 'new')
Searchable as RT131413$
The text was updated successfully, but these errors were encountered: