Skip Menu |
Report information
Id: 132307
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [MOAR] Slurpy positionals cause type constraints to be ignored on named args
Download (untitled) / with headers
text/plain 1.4k
The following code tries to pass Str `:bin` named arg to a Code that wants an `Int` `:bin` arg. The typecheck correctly fails, but only if no positional slurpies are present in the signature. <Zoffix__> m: -> Int :$bin {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «Type check failed in binding to parameter '$bin'; expected Int but got Str ("x")␤ in block <unit> at <tmp> line 1␤␤» <Zoffix__> m: -> *@, Int :$bin {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «[x Str]␤» <Zoffix__> m: -> +@, Int :$bin {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «[x Str]␤» <Zoffix__> m: -> **@, Int :$bin {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «[x Str]␤» <Zoffix__> m: -> Int :$bin, *%_ {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «Type check failed in binding to parameter '$bin'; expected Int but got Str ("x")␤ in block <unit> at <tmp> line 1␤␤» <Zoffix__> m: -> Int :$bin, | {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «Type check failed in binding to parameter '$bin'; expected Int but got Str ("x")␤ in block <unit> at <tmp> line 1␤␤» NOTE: fixing this will likely have some fallout to watch out for, including test breakage in core (e.g., as I write this, accessing $*ARGFILES would've been crashing, as its instantiated with an Int for `:bin` instead of a Bool)
Download (untitled) / with headers
text/plain 109b
P.S.: this problem appears to not exist on JVM per https://irclog.perlgeek.de/perl6-dev/2017-10-15#i_15304908
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 624b
Another couple of datapoints (IRC: https://irclog.perlgeek.de/perl6-dev/2017-10-15#i_15305041): The `where` clause gets run even when types don't typecheck and its return value still affects the typecheck: <Zoffix__> m: -> *@, Int :$bin where {sleep 2; True} {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «[x Str]␤» <Zoffix__> m: -> *@, Int :$bin where {sleep 2; False} {say [$bin, $bin.^name]}(:bin<x>) <camelia> rakudo-moar ebb0521bd: OUTPUT: «Type check failed in binding to parameter '$bin'; expected Int but got Str ("x")␤ in block <unit> at <tmp> line 1␤␤»


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org