Skip to content
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

Coercers as parameter parametarizers give wild results #2319

Open
zoffixznet opened this issue Sep 24, 2018 · 1 comment
Open

Coercers as parameter parametarizers give wild results #2319

zoffixznet opened this issue Sep 24, 2018 · 1 comment

Comments

@zoffixznet
Copy link
Contributor

No idea if such a thing can be made to work, at all, but if it can't it should throw instead of binding an Int to a @- param.

<Zoffix_> m: -> Int() @v { dd @v }(Array[Any].new: 1, 2, 34, 6)
<camelia> rakudo-moar 645eeb52d: OUTPUT: «4␤»
<Zoffix_> m: -> Int() @v { dd @v.^name }(Array[Any].new: 1, 2, 34, 6)
<camelia> rakudo-moar 645eeb52d: OUTPUT: «"Int"␤»
@vrurg
Copy link
Member

vrurg commented Nov 30, 2020

Works as expected with the latest coercion semantics.

⇒ raku -e '-> Int() @v { dd @v }(Array[Any].new: 1, 2, 34, 6)'
Array[Any].new(1, 2, 34, 6)

Yet, because @v gets bound, not assigned, to the function argument, no coercion is applied. So, if any of the argument array elements is not an Int, it will be preserved.

Not closing the ticket now because the situation about non-coerced elements perhaps worth considering changing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants