# New Ticket Created by  David Warring 
# Please include the string:  [perl #132222]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=132222 >


From
https://docs.perl6.org/language/nativecall#Embedding_CStructs_and_CUnions

class Point is repr('CStruct') {
    has uint16 $.x;
    has uint16 $.y;
}

class MyStruct2 is repr('CStruct') {
    HAS Point $.point;  # <-- embedded
    has int32 $.flags;
}

my $s = MyStruct2.new;
say $s.flags;
say $s.point.defined;
say $s.point.x;

Produces:

0
False
Cannot look up attributes in a Point type object
 in block <unit> at /tmp/tst.pl line 15

Ie, the embedded struct is not automatically created and defined, when a
new containing struct is created.

Rakudo version 2017.09-199-gc91c40115 built on MoarVM version
2017.09.1-62-g89ca8eb0
implementing Perl 6.c.

Reply via email to