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

:U parametarized@,%,& parameters are incorrectly parametarized #2298

Open
zoffixznet opened this issue Sep 20, 2018 · 2 comments
Open

:U parametarized@,%,& parameters are incorrectly parametarized #2298

zoffixznet opened this issue Sep 20, 2018 · 2 comments

Comments

@zoffixznet
Copy link
Contributor

If you parametarize with a :D constraint, everything is peachy:

17:49 | Zoffix | m: -> Int:D @v { @v[^3] }(my Int:D @)
-- | -- | --
17:49 | camelia | rakudo-moar c9432c207: ( no output )

But if you use :U instead, then it appears as if the :U is applied to the constraint offered by the sigil (Positional/Associative/Callable) instead of the value it's parametarized with:

17:49 | Zoffix | m: -> Int:U @v { @v[^3] }(my Int:U @)
17:49 | camelia | rakudo-moar  c9432c207: OUTPUT: «Parameter '@v' of routine '<anon>' must be a  type object of type 'Positional[Int]', not an object instance of type  'Array[Int:U]'. Did you forget a 'multi'?␤ in block <unit> at  <tmp> line 1␤␤»
1352    @Zoffix │ m: my $b := -> Int:U @v { @v[^3] }; my \a := $b.signature.params.head.type; dd $b(a)                                                                 │
1352   +camelia │ rakudo-moar c9432c207: OUTPUT: «(Any, Any, Any)␤»


1353    @Zoffix │ m: -> Int:U %v { %v<a b c> }(my Int:U %)                                                                                                             │
1353   +camelia │ rakudo-moar c9432c207: OUTPUT: «Parameter '%v' of routine '<anon>' must be a type object of type 'Associative[Int]', not an object instance of type  │
                │ 'Hash[Int:U]'.  Did you forget a 'multi'?␤  in block <unit> at <tmp> line 1␤␤»


1354    @Zoffix │ m: -> Int:U &v { }(sub (--> Int:U) {})                                                                                                               │
1354   +camelia │ rakudo-moar c9432c207: OUTPUT: «Parameter '&v' of routine '<anon>' must be a type object of type 'Callable[Int]', not an object instance of type     │
                │ 'Sub+{Callable[Int:U]}'.  Did you forget a 'multi'?␤  in block <unit> at <tmp> line 1␤␤»
@zoffixznet
Copy link
Contributor Author

zoffixznet commented Sep 20, 2018

There are some fudged tests in Raku/roast@8c8e8f55bb#diff-d442fea62726a360de696ce38077fcebR159 that may be sufficient to cover this bug.

@jnthn
Copy link
Member

jnthn commented Sep 20, 2018

I wonder if it's accidentally somehow distributing the :U across both, and with the :D we just don't notice.

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

No branches or pull requests

3 participants