7

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?

Fernando Santagata
  • 1,487
  • 1
  • 8
  • 15
  • Declaring `test1` and using it by itself also works... Declaring A and instantiating it causes no problem either, either in 2018.03 or 2018.06. Can you please try and check again? – jjmerelo Jul 01 '18 at 10:48
  • 1
    If you remove the `[void]` it doesn't generate that error. – Brad Gilbert Jul 01 '18 at 15:57

1 Answers1

1

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

Fernando Santagata
  • 1,487
  • 1
  • 8
  • 15