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

Composing an inherited class through a parametric role doesn't work in Rakudo #2679

Open
p6rt opened this issue Mar 21, 2012 · 7 comments
Open

Comments

@p6rt
Copy link

p6rt commented Mar 21, 2012

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

Searchable as RT111912$

@p6rt
Copy link
Author

p6rt commented Mar 21, 2012

From @masak

<moritz> nom​: role A[​::T $] { also is T }; class B { }; class C does
A[B] { }; say C ~~ B
<p6eval> rakudo 1a468d​: OUTPUT«===SORRY!===␤Cannot type check against
type variable T␤»
<moritz> that's... somwhere between LTA and wrong, I'm not sure where
exactly it is :-)
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

From @smls

On Wed, 21 Mar 2012 08​:32​:55 -0700, masak wrote​:

<moritz> nom​: role A[​::T $] { also is T }; class B { }; class C does
A[B] { }; say C ~~ B
<p6eval> rakudo 1a468d​: OUTPUT«===SORRY!===␤Cannot type check against
type variable T␤»

Now it throws earlier, and with a nicer error message​:

  ===SORRY!=== Error while compiling -e
  T does not support inheritance, so A cannot inherit from it

Not sure if it can be made to work like you wanted.

Not sure if it can be made to actually work (i.e. defer the `also is T` until class composition time, at which point the concrete type of T would be available).

Seems related to​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=130634

@p6rt
Copy link
Author

p6rt commented Sep 10, 2017

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

@p6rt p6rt added the Bug label Jan 5, 2020
@usev6
Copy link

usev6 commented Oct 7, 2023

It looks like this works now as expected:

$ ./rakudo-m -e 'role A[::T $] { also is T }; class B {}; class C does A[B] {}; say C ~~ B'
True

Tagging "testneeded".

@masak
Copy link

masak commented Oct 8, 2023

I'm actually a little bit shocked that this works. My mental model needs to do some stretching exercises before attempting to cover a semantics where this Just Works. I'm now very curious, and might dip into the implementation just to see what's going on. (Note message from smls in 2017, "Not sure if it can be made to work like you wanted.")

Is it the case that the role body contains a... "script" (with possibly-late-bound things like T) which executes on role composition (after substituting B into T)? That's the only way I can imagine this working at all.

@usev6
Copy link

usev6 commented Oct 8, 2023

For the record -- and maybe helpful if you want to look at the implementation: According to bisectable6 (https://colabti.org/irclogger/irclogger_log/raku-dev?date=2023-10-08#l10) the behavior changed (from dying with T does not support inheritance, so A cannot inherit from it to printing True) with commit rakudo/rakudo@4b99656875.

@masak
Copy link

masak commented Oct 8, 2023

That is indeed helpful. Thank you! I can't say I follow the diff perfectly, but the commit message indeed settles whether this was a deliberate move or not.

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

No branches or pull requests

3 participants