Skip Menu |
Report information
Id: 130663
Status: open
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: Sun, 4 Sep 2016 10:20:17 +0200
Subject: problem mixing in role with multi builds
From: mt1957 <mt1957 [...] gmail.com>
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 627b
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
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 3.9k
On Sat, 28 Jan 2017 16:42:46 -0800, mt1957@gmail.com wrote: Show quoted text
> 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
Some observations: 1) All submethods are affected and sticking `Any` or `Mu` into invocant doesn't help (perhaps correctly, because these are *sub*methods?): <Zoffix> m: role RR {}; class Foo { multi submethod foo($x) { $x.say } }; (Foo.new does RR).foo: 42 <camelia> rakudo-moar aac9ef: OUTPUT«Cannot resolve caller foo(Foo+{RR}: Int); none of these signatures match:␤ (Foo $: $x, *%_)␤ in block <unit> at <tmp> line 1␤␤» <Zoffix> m: role RR {}; class Foo { multi submethod foo(Any: $x) { $x.say } }; (Foo.new does RR).foo: 42 <camelia> rakudo-moar aac9ef: OUTPUT«Cannot resolve caller foo(Foo+{RR}: Int); none of these signatures match:␤ ($: $x, *%_)␤ in block <unit> at <tmp> line 1␤␤» <Zoffix> m: role RR {}; class Foo { multi submethod foo(Mu $: $x) { $x.say } }; (Foo.new does RR).foo: 42 <camelia> rakudo-moar aac9ef: OUTPUT«Cannot resolve caller foo(Foo+{RR}: Int); none of these signatures match:␤ (Mu $: $x, *%_)␤ in block <unit> at <tmp> line 1␤␤» 2) Functionality of multi submethods seems busted. For example here's the multi no match error occurs: <Zoffix> m: class Bar { multi submethod BUILD() {} }; class Foo is Bar {}.new <camelia> rakudo-moar aac9ef: OUTPUT«Cannot resolve caller BUILD(Foo: ); none of these signatures match:␤ (Bar $: *%_)␤ in block <unit> at <tmp> line 1␤␤» But goes away if we use the second class in the invocant: <Zoffix> m: class Foo {…};class Bar { multi submethod BUILD(Foo:) {} }; class Foo is Bar {}.new <camelia> rakudo-moar aac9ef: ( no output ) 3) The multi build works in this configuration of being in role and class and role being mixed in advance: <Zoffix> m: role RR {multi submethod BUILD(:$x!) {say "role"}}; class Foo does RR { multi submethod BUILD(:$y!) {say "hi"} }; Foo.new: :x <camelia> rakudo-moar aac9ef: OUTPUT«role␤» <Zoffix> m: role RR {multi submethod BUILD(:$x!) {say "role"}}; class Foo does RR { multi submethod BUILD(:$y!) {say "hi"} }; Foo.new: :y <camelia> rakudo-moar aac9ef: OUTPUT«hi␤» As long as invocant marker matches the class the submethod's in: <Zoffix> m: role RR {multi submethod BUILD(:$x!) {say "role"}}; class Foo does RR { multi submethod BUILD($: :$y!) {say "hi"} }; Foo.new: :y <camelia> rakudo-moar aac9ef: OUTPUT«Cannot resolve caller BUILD(Foo: :y); none of these signatures match:␤ ($: :$y!, *%_)␤ (Foo $: :$x!, *%_)␤ in block <unit> at <tmp> line 1␤ 4) Getting this weird error about two unnamed parameters, which happens only when I use `:$` named in class and try to mix in a role that has another multi with some named param. waat: <Zoffix> m: class Foo { multi submethod BUILD(:$) {say "hi"} }; Foo.new <camelia> rakudo-moar aac9ef: OUTPUT«hi␤» <Zoffix> m: role RR {multi submethod BUILD() {say "role"}}; class Foo does RR { multi submethod BUILD(:$) {say "hi"} }; Foo.new <camelia> rakudo-moar aac9ef: OUTPUT«hi␤» <Zoffix> m: role RR {multi submethod BUILD(:$x) {say "role"}}; class Foo does RR { multi submethod BUILD(:$) {say "hi"} }; Foo.new <camelia> rakudo-moar aac9ef: OUTPUT«===SORRY!=== Error while compiling <tmp>␤Found named parameter '(unnamed)' twice in signature :(Foo $: $, *%_): *%_ vs $␤at <tmp>:1␤»


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