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

Type dispatch problems when nesting in and inheriting from the same class in Rakudo #3232

Open
p6rt opened this issue Sep 12, 2013 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 12, 2013

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

Searchable as RT119759$

@p6rt
Copy link
Author

p6rt commented Sep 12, 2013

From @masak

<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.

@p6rt
Copy link
Author

p6rt commented Nov 28, 2015

From @Mouq

On Thu Sep 12 11​:28​:26 2013, masak wrote​:

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

@p6rt
Copy link
Author

p6rt commented Nov 28, 2015

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

@p6rt p6rt added the Bug 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