# New Ticket Created by Curt Tilmes # Please include the string: [perl #131311] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=131311 >
If I have embedded (with 'HAS', not referenced with 'has') CStruct or CUnions, and set the first field in the embedded struct to a 0 (looks like a NULL pointer?) I get an incorrect error message about the struct being a 'type object' (undefined) Perhaps easiest to demonstrate with an example: $ cat foo.h #include <inttypes.h> typedef struct foo { struct { uint64_t a; } data; } foo_t; extern void fill_foo(foo_t *f, uint64_t a); $ cat foo.c #include "foo.h" void fill_foo(foo_t *f, uint64_t a) { f->data.a = a; } $ gcc -c -Wall -Werror -fpic foo.c $ gcc -shared -o libfoo.so foo.o $ perl6 -v This is Rakudo version 2017.04.3-47-gf0414c4 built on MoarVM version 2017.04-44-gf0db882 implementing Perl 6.c. $ cat fooperl.pl use v6; use NativeCall; class data is repr('CStruct') { has uint64 $.a; } class foo is repr('CStruct') { HAS data $.data; } sub fill_foo(foo, uint64) is native('foo') {*} my $foo = foo.new; fill_foo($foo, 27); say $foo.data.a; # Works fine, data looks 'defined' fill_foo($foo, 0); say $foo.data.a; # Error, data looks 'undefined'? $ perl6 fooperl.pl 27 Cannot look up attributes in a data type object in block <unit> at fooperl.pl line 23