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
Coercion type apparently does not check the actual type of the coerced value #6656
Comments
From @briandfoyI was playing with coercion types and wondered what would happen if class Foo { put try-it( Foo.new ); sub try-it ( Int() $n ) { "Got <$n> of type <{$n.^name}>" } Although the subroutine signature demanded an Int, it accepted Got <Hello> of type <Str> I would have expected the runtime constraint to check the ultimate -- |
From @zoffixznetOn Wed, 14 Mar 2018 14:16:06 -0700, comdog wrote:
Thanks for the report. We'll likely want to extend the features of the coercers, and include the return I've documented[^1] that no check is currently performed on the result and there I've tried[^3] implementation[^4] of checking the final result in January and it [1] Raku/doc@ee34834195 |
The RT System itself - Status changed from 'new' to 'open' |
@zoffixznet - Status changed from 'open' to 'resolved' |
@zoffixznet - Status changed from 'resolved' to 'open' |
From @zoffixznetRe-opening this, as there's a much more common case where a typecheck of the coercion result would be desired and that's when coercion results in a Failure: <Zoffix_> m: multi sub foo(Int() $) { }; foo Inf |
Quoting brian's opening comment:
In recent Rakudos the above code displays:
|
So it would appear this can be closed? |
Quoting zoffix's last comment:
That this works without an error is consistent with how the rest of Raku works. For example:
silently works, as intended. This is the point of
displays:
So perhaps this issue should be closed. |
Thanks for the headsup! |
I do wonder if this should promote the failure to an immediate exception:
(One of the reasons I'm revisiting this issue is I'm pondering the whole While I really like the way Raku type objects play the role other PLs assign to Maybe aka Option, it feels like explicitly specifying a |
Migrated from rt.perl.org#132980 (status was 'open')
Searchable as RT132980$
The text was updated successfully, but these errors were encountered: