Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange message declaring a Pointer[void] in a NativeCall perl6 module

These snippets of code may seem odd, it's because I started with my original code and cut off pieces until I arrived to the minimal set of instructions that reproduced the error. So bear with the apparent uselessness. There are two perl6 modules, one uses the other one, and a program. This is the first module:

unit class test1;

use NativeCall;
use test2;

method test
{
  my Pointer[void] $dummy .= new;
}

The second module is included by the first one, but no part of it is actually used:

unit module test2;

use NativeCall;

class A is repr('CStruct') is export {
  has Pointer[void] $.wrongdoer;
  has int32 $.a;
}

The program creates a test1 object and calls the test method:

use lib '.';
use test1;

my test1 $t .= new;
$t.test;

This program outputs an error, apparently caused by the assignment in the class test1's method test:

Type check failed in assignment to $dummy; expected NativeCall::Types::Pointer[NativeCall::Types::void] but got NativeCall::Types::Pointer[NativeCall::Types::void].new(0)

If I comment out the $.wrongdoer in the second class, the program executes with no error. I'm running rakudo 2018.06. Is this a bug in the NativeCall module or something else I fail to see?

like image 574
Fernando Santagata Avatar asked Jul 01 '18 10:07

Fernando Santagata


1 Answers

As suggested by Brad Gilbert, removing the [void] stops the spooky action at a distance.

like image 166
Fernando Santagata Avatar answered Oct 20 '22 19:10

Fernando Santagata