Skip Menu |
Report information
Id: 132052
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: vittore.scolari [at]

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

From: Vittore Scolari <vittore.scolari [...]>
Subject: [BUG] size passed as parameter to parametric method die with error
Date: Sun, 10 Sep 2017 01:10:08 +0200
To: rakudobug [...]
Download (untitled) / with headers
text/plain 501b
The following script:

    use NativeCall :types;

    class a {
       method new(size_t $size, :$init, :$type) {
           my $s = $size;   

   my $a =;

   class b {
       method new(size_t $size, :$init, :$type) {

    my $b =;

dies with error
Type check failed in initializing element #0 to Blob[NativeCall::Types::size_t]; expected NativeCall::Types::size_t but got Int (12)

Download (untitled) / with headers
text/plain 846b
It doesn't seem to be specific to type `size_t` - it also happens with other native types such as `int`. Shorter example: ➜ sub a (int $a) { Blob[int].new($a) }; say a 12; Type check failed in initializing element #0 to Blob[int]; expected int but got Int (12) Examples that *don't* fail: ➜ sub a (int $a is copy) { Blob[int].new($a) }; say a 12; Blob[int]:0x<0c> ➜ sub a (Int $a) { Blob[int].new($a) }; say a 12; Blob[int]:0x<0c> ➜ my int $a = 12; say Blob[int].new($a); Blob[int]:0x<0c> I think it's safe to say that in all four cases, `$a` gets boxed to an `Int`. But in the first case, it's as if the Blob constructor nonetheless uses the code path for `int` and subsequently gets surprised. Maybe the `int $a` signature leads the compiler to think that it will always be an `int`?

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

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