FAQ
# New Ticket Created by Jonathan Stowe
# Please include the string: [perl #128211]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=128211 >


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.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupperl6-compiler @
categoriesperl
postedMay 22, '16 at 12:42p
activeMay 22, '16 at 12:42p
posts1
users1
websiteperl6.org

1 user in discussion

Jonathan Stowe: 1 post

People

Translate

site design / logo © 2019 Grokbase