develooper Front page | perl.perl6.users | Postings from June 2020

an error I don't understand

Thread Next
From:
Marcel Timmerman
Date:
June 27, 2020 15:56
Subject:
an error I don't understand
Message ID:
b6cb8eab-75f4-ae0e-2582-fb37845ca9bf@gmail.com
Hi,

I am getting an error and don't know why it happens, it might even be a 
bug. It is about an assignment to a CStruct variable.

The structure is defined like;

class cairo_path_data_point_t is repr('CStruct') is export {
   has num64 $.x;
   has num64 $.y;

   submethod TWEAK ( :$native-object ) {
     $!x = $native-object.x;
     $!y = $native-object.y;
   }
}


The error is generated when typed variables are used (below, $x is also 
a cairo_path_data_point_t);

my cairo_path_data_point_t $p1 = $x;

or

my cairo_path_data_point_t $p1 = 
cairo_path_data_point_t.new(:native-object($x));

but not with

my cairo_path_data_point_t $p1 .= new(:native-object($x));

or

my $p1 = $x;

After which all fields in the structure are happely accessable using $p1!


The error is

Type check failed in assignment to $p1; expected cairo_path_data_point_t 
but got cairo_path_data_point_t.new(x => 0e0, y => 0e0)


Raku version: 2020.06-7-gf1960baa9 built on MoarVM version 
2020.06-6-gbf6af07de
implementing Raku 6.d.

The content of the structure does not matter, I've seen it with other 
structures too.

Regards,
Marcel

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About