> On 01 May 2016, at 16:43, Itsuki Toyota (via RT)
> <[email protected]> wrote:
>
> # New Ticket Created by Itsuki Toyota
> # Please include the string: [perl #128049]
> # in the subject line of all future correspondence about this issue.
> # <URL: https://rt.perl.org/Ticket/Display.html?id=128049 >
>
>
> See the following results.
>
> $ perl6 -MNativeCall -e 'class Foo { has $.piyo; method new() { my $fuga =
> CArray[OpaquePointer]; $fuga[0] = OpaquePointer; $!piyo = $fuga[0]; } };
> Foo.new();'
> Cannot look up attributes in a type object
> in method new at -e line 1
> in block <unit> at -e line 1
>
This is not a bug and has nothing to do with NativeCall:
$ 6 'class A { has $!a; method a() { $!a = 42 } }; A.a'
Cannot look up attributes in a type object
in method a at -e line 1
in block <unit> at -e line 1
The “self” in new is a type object, *not* an instance.
$ 6 'class A { has $!a; method a() { $!a = 42 } }; say A.new.a’
42
The default .new will return an instantiated object.
You should probably rename your method “new” to BUILD, so that the default
.new() implementation can find it.
Liz