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

multi BUILD defined in role gets messed up in sub-class #5334

Open
p6rt opened this issue May 22, 2016 · 1 comment
Open

multi BUILD defined in role gets messed up in sub-class #5334

p6rt opened this issue May 22, 2016 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented May 22, 2016

Migrated from rt.perl.org#128211 (status was 'new')

Searchable as RT128211$

@p6rt
Copy link
Author

p6rt commented May 22, 2016

From @jonathanstowe

Consider the following​:

role Foo {
  has $!attribute;
  multi submethod BUILD(Str :$!attribute!) {
  say "with attribute";
  }
}

class Bar does Foo {
  multi submethod BUILD(Str :$foo!) {
  say "with foo";
  $!attribute = "default";
  }

  method foo() {
  say $!attribute;
  }
}

class Zub is Bar {
}

Bar.new(attribute => "set").foo;
Bar.new(foo => "something").foo;

Zub.new(attribute => "set").foo;
Zub.new(foo => "something").foo;

Resulting in​:

with attribute
set
with foo
default
Cannot call BUILD(Zub​: Str); none of these signatures match​:
  (Bar $​: Str :$foo!, *%_)
  (Bar $​: Str :attribute($!attribute)!, *%_)
  in block <unit> at tt line 25

It appears that it is trying to call the BUILD with a *positional* in the sub-class, however supplying the candidate that it reports it is trying to call doesn't effect the outcome, which is somewhat odd in itself.

Unfortunately the call path which leads to this state of affairs is not clear to me at all.

@p6rt p6rt added the oo label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant