This works:

my int32 $a = 3; my int32 $b = 7; say $a * $b # OUTPUT: «21␤»

El dom., 30 sept. 2018 a las 11:28, Fernando Santagata (<
nando.santag...@gmail.com>) escribió:

> Hi,
>
> I was hunting for a bug in my code, this one:
>
> my @a := CArray[int32].new: 6,3;
> say [+] @a; # it should be "say [+] @a.list;"
>
> That statement prints "9", while changing the '+' with a '*' it generates
> an error, as it should:
>
> Cannot resolve caller Numeric(NativeCall::Types::CArray[int32]: ); none of
> these signatures match:
>     (Mu:U \v: *%_)
>
> Is this a bug, an inconsistency, or a necessary evil?
>

It's difficult to say. Some conversion is taking place somewhere to
Numeric, and it's getting stuff it does not like. The type is
NativeCall::Types::CArray[int32].new and it's being considered a single
item; it's attempting conversion to Numeric. The thing here is that CArray
is actually not an Array; it inherits directly from Any:

    say @a.^mro; # OUTPUT: «((CArray[int32]) (CArray) (Any) (Mu))␤»

It does include a `list` for convenience, but it's not, by itself, a list.
That operator does not do the conversion, but expects it to be a list,
hence the error.

Hope this helps

JJ

Reply via email to