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

Accidental use of 'is' with a role in class declaration causes 'No concretization' error #2659

Closed
vrurg opened this Issue Jan 30, 2019 · 9 comments

Comments

Projects
None yet
5 participants
@vrurg
Copy link
Contributor

vrurg commented Jan 30, 2019

The Problem

If by a class is inheriting from a role instead of doing it then class-qualified calls to role methods fail with 'No concretization found' exception.

Steps to Reproduce

The following code demosntrated the problem:

 role R2 {
     method foo {
         "R2::foo"
     }
 }
 class Foo is R2 {
     method foo {
         say "Foo::foo" ~ callsame;
     }
 }
 Foo.new.foo;

Environment

  • Operating system: macOS, Linux
  • Compiler version (perl6 -v): This is Rakudo version 2018.12 built on MoarVM version 2018.12
    Also tested on 2018.08 and 2017.10
@lizmat

This comment has been minimized.

Copy link
Contributor

lizmat commented Jan 30, 2019

Cannot reproduce this on blead:

This is Rakudo version 2018.12-269-gc2e272e built on MoarVM version 2018.12-45-ga9d0257
@jonathanstowe

This comment has been minimized.

Copy link
Contributor

jonathanstowe commented Jan 30, 2019

Neither for me, I was expecting 'Did you mean to use "does" instead?'' but I guess it is punned somehow before adding the new parent. If that is the case is there a way of having the role to indicate that it shouldn't be inherited from as I'm pretty sure the difference between the two may be significant in some cases.

@lizmat

This comment has been minimized.

Copy link
Contributor

lizmat commented Jan 30, 2019

To prevent a role from being punned, ::?ROLE.HOW.archetypes..inheritalizable should return a false value at compile time. It will then die with a X::Inheritance::Unsupported exception. Leaving this as an exercise to the reader on how to make that happen, and what syntactic sugar we will devise for that.

@jonathanstowe

This comment has been minimized.

Copy link
Contributor

jonathanstowe commented Jan 30, 2019

Need a new trait word : isn't so we can have role Foo isn't inheritalizable { } ;-)

@jnthn

This comment has been minimized.

Copy link
Member

jnthn commented Jan 30, 2019

Use of a role with is is a deliberate feature, and actually the point of inheritalizable ("am I able to turn this into something I can inherit from?") even existing. The result is to pun the role, and then inherit from that.

The callsame behavior looks a bit broken, however.

@vrurg

This comment has been minimized.

Copy link
Contributor Author

vrurg commented Jan 30, 2019

I'm very sorry for a mistake. While playing with different variants of the code I chose a wrong one to post. The problematic version is following:

 role R2 {
     method foo {
         "R2::foo"
     }
 }
 class Foo is R2 {
     method foo {
         say "Foo::foo", self.R2::foo;
     }
 }
 Foo.new.foo;

And it fails on blead as well as on 2018.12.

BTW, this is likely to be related to #2657

@lizmat

This comment has been minimized.

Copy link
Contributor

lizmat commented Jan 30, 2019

FWIW, this gives the same error:

role R2 {
    method foo {
        "R2::foo"
    }
}
my constant R3 = R2.^pun;
class Foo is R3 {
    method foo {
        say "Foo::foo", self.R2::foo;
    }
}
Foo.new.foo;

which indicates to me that the self.R2::foo syntax is not looking for a punned R2. And indeed, if we replace it by self.R3::foo, it all works as expected.

@AlexDaniel AlexDaniel added LTA and removed LTA labels Jan 30, 2019

@vrurg

This comment has been minimized.

Copy link
Contributor Author

vrurg commented Feb 6, 2019

Pull request #2675 fixes this issue as well as two other with similar sympthoms.

jnthn added a commit that referenced this issue Feb 7, 2019

@jnthn

This comment has been minimized.

Copy link
Member

jnthn commented Feb 7, 2019

Merged PR and also tests in perl6/roast@6b3d51c cover this.

@jnthn jnthn closed this Feb 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.