Skip Menu |
Report information
Id: 119759
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

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



Subject: [BUG] Type dispatch problems when nesting in and inheriting from the same class in Rakudo
Date: Thu, 12 Sep 2013 20:28:03 +0200
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Download (untitled) / with headers
text/plain 1.5k
<timotimo> masak: https://github.com/masak/crypt/blob/master/t/hanoi.t#L5 - can you imagine why this would explode with this error: Nominal type check failed for parameter ''; expected Any but got LargerOnSmaller instead (when called from line 39) <timotimo> as far as i can see, LargerOnSmaller is derived from X::Hanoi <timotimo> and X::Hanoi is Exception <timotimo> r: class X::Hanoi is Exception { class LargerOnSmaller is X::Hanoi { method message { "you can't do that" } } }; sub testsub($ex_type) { say $ex_type; }; testsub(X::Hanoi::LargerOnSmaller); <camelia> rakudo 69c3cc: OUTPUT«Nominal type check failed for parameter '$ex_type'; expected Any but got LargerOnSmaller instead␤ in sub testsub [...] <timotimo> r: class X::Hanoi is Exception { class LargerOnSmaller is X::Hanoi { method message { "you can't do that" } } }; sub testsub(Mu:U $ex_type) { say $ex_type.message; }; testsub(X::Hanoi::LargerOnSmaller); <camelia> rakudo 69c3cc: OUTPUT«you can't do that␤» <timotimo> i'm kind of getting the feeling that putting the class definition into the other class is making it bork <masak> r: class A is Exception { class B is A {} }; sub foo($x) {}; foo(A::B) <camelia> rakudo 69c3cc: OUTPUT«Nominal type check failed for parameter '$x'; expected Any but got B instead␤ in sub foo [...] <masak> timotimo: yes. * masak submits rakudobug <masak> r: class A is Exception {}; class C { class B is A {} }; sub foo($x) {}; foo(C::B) <camelia> rakudo 69c3cc: ( no output ) <masak> hm; nesting in the same class you inherit from seems to be a required part of the problem.
Download (untitled) / with headers
text/plain 1.9k
On Thu Sep 12 11:28:26 2013, masak wrote: Show quoted text
> <timotimo> masak: > https://github.com/masak/crypt/blob/master/t/hanoi.t#L5 - can you > imagine why this would explode with this error: Nominal type check > failed for parameter ''; expected Any but got LargerOnSmaller instead > (when called from line 39) > <timotimo> as far as i can see, LargerOnSmaller is derived from > X::Hanoi > <timotimo> and X::Hanoi is Exception > <timotimo> r: class X::Hanoi is Exception { class LargerOnSmaller is > X::Hanoi { method message { "you can't do that" } } }; sub > testsub($ex_type) { say $ex_type; }; > testsub(X::Hanoi::LargerOnSmaller); > <camelia> rakudo 69c3cc: OUTPUT«Nominal type check failed for > parameter '$ex_type'; expected Any but got LargerOnSmaller instead␤ > in sub testsub [...] > <timotimo> r: class X::Hanoi is Exception { class LargerOnSmaller is > X::Hanoi { method message { "you can't do that" } } }; sub > testsub(Mu:U $ex_type) { say $ex_type.message; }; > testsub(X::Hanoi::LargerOnSmaller); > <camelia> rakudo 69c3cc: OUTPUT«you can't do that␤» > <timotimo> i'm kind of getting the feeling that putting the class > definition into the other class is making it bork > <masak> r: class A is Exception { class B is A {} }; sub foo($x) {}; > foo(A::B) > <camelia> rakudo 69c3cc: OUTPUT«Nominal type check failed for > parameter '$x'; expected Any but got B instead␤ in sub foo [...] > <masak> timotimo: yes. > * masak submits rakudobug > <masak> r: class A is Exception {}; class C { class B is A {} }; sub > foo($x) {}; foo(C::B) > <camelia> rakudo 69c3cc: ( no output ) > <masak> hm; nesting in the same class you inherit from seems to be a > required part of the problem.
Now dies with: 05:07 <Quom_> m: class A is Exception { class B is A {} }; sub foo($x) {}; foo(A::B) 05:07 <camelia> rakudo-moar a148bf: OUTPUT«===SORRY!=== Error while compiling /tmp/KuNuqLVEqd␤'A::B' cannot inherit from 'A' because 'A' isn't composed yet (maybe it is stubbed)␤at /tmp/KuNuqLVEqd: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