Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem mixing in role with multi builds #6038

Open
p6rt opened this issue Jan 29, 2017 · 3 comments
Open

problem mixing in role with multi builds #6038

p6rt opened this issue Jan 29, 2017 · 3 comments

Comments

@p6rt
Copy link

p6rt commented Jan 29, 2017

Migrated from rt.perl.org#130663 (status was 'open')

Searchable as RT130663$

@p6rt
Copy link
Author

p6rt commented Jan 29, 2017

From @MARTIMM

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

@p6rt
Copy link
Author

p6rt commented Feb 13, 2017

From @zoffixznet

On Sat, 28 Jan 2017 16​:42​:46 -0800, mt1957@​gmail.com wrote​:

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␤»

@p6rt
Copy link
Author

p6rt commented Feb 13, 2017

The RT System itself - Status changed from 'new' to 'open'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant