Skip Menu |
Report information
Id: 129212
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: mt1957 [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Tue, 6 Sep 2016 14:18:45 +0200
To: rakudobug [...] perl.org
From: mt1957 <mt1957 [...] gmail.com>
Subject: problem mixing in role with multi builds
Download (untitled) / with headers
text/plain 776b
Hi, I get the following error using version 2016.08.1-66-g1ff1aae built on MoarVM version 2016.08 implementing Perl 6.c. Cannot resolve caller BUILD(CC+{RR}: ); none of these signatures match: (CC $: Str :$t!, *%_) (CC $: Int :$i!, *%_) in block <unit> at Build2.pl6 line 15 The code which generates the error (on the line with '$c does RR'); role RR { } class CC { multi submethod BUILD ( Str :$t! ) { } multi submethod BUILD ( Int :$i! ) { } } my CC $c .= new(:t<text1>); $c does RR; Removing the last line and add a trait 'does' to the class works but is not what I want. Greetings, Marcel P.s. I've sent this mail before to rakudobug but I did not see it appear in the list. Sorry for duplication if it did appear somewhere else.
Subject: Re: [perl #129212] problem mixing in role with multi builds
To: perl6-compiler [...] perl.org
Date: Mon, 17 Oct 2016 14:56:47 +0200
From: mt1957 <mt1957 [...] gmail.com>
Download (untitled) / with headers
text/plain 1.3k
Hi, Revisiting the problem using rakudo version 2016.10-31-g6ed3a68 built on MoarVM version 2016.10 implementing Perl 6.c. The issue still exist but tried to rewrite things to get it working role RR1 { submethod BUILD ( Int :$i ) { say $i // 'No i'; } } role RR2 { submethod BUILD ( Str :$t ) { say $t // 'No t'; } } class CC { multi submethod BUILD ( Int :$i! ) { say "Integer $i"; self does RR1; } multi submethod BUILD ( Str :$t! ) { say "String $t"; self does RR2; } } for <t i> { when 'i' { my CC $c .= new(:i(10)); } when 't' { my CC $c .= new(:t<text1>); } } This version works, but output is String text1 No t Integer 10 No i This means that the BUILD submethods in the roles are called without arguments, while the signatures must be the same from the use in the class. The required '!' must be removed(no arguments delivered). The roles, if needed, must be initialized with a later call, e.g. via method init(Int $i) to get the values in the role. Removing the submethods BUILD from the roles will trigger again the exception; Cannot resolve caller BUILD(CC+{RR1}: ); none of these signatures match: (CC $: Str :$t!, *%_) (CC $: Int :$i!, *%_) in block at Does.pl6 line 23 in block <unit> at Does.pl6 line 20 Greetings Marcel


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org