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

Partial fix of mixing in a role with attributes into a NQP class #3834

Merged
merged 2 commits into from Jul 31, 2020

Conversation

vrurg
Copy link
Member

@vrurg vrurg commented Jul 30, 2020

When a Raku role with an attribute is mixed into a metamodel or NQP class rakudo throws X::Method::NotFound:

role Foo { has Mu $.bar }
"foo".HOW does Foo;

This PR is a fix. It also fixes X::Method::NotFound exception message code failing on KnowHOW objects because their methods method returns the method table, not a list of methods.

@vrurg
Copy link
Member Author

vrurg commented Jul 30, 2020

The fix is partial as parameterized roles with an attribute still throw when role parameter is assigned to the attribute:

role Foo[$p] {
    has $.foo = $p;
}
"42".HOW does Foo["The Answer"];

With this PR the exception produced is X::TypeCheck::Binding::Parameter. Looks like a problem with a build plan produced for the attribute but can't tell more.

@vrurg
Copy link
Member Author

vrurg commented Jul 30, 2020

Upd Full fix includes Raku/nqp#650

vrurg added a commit to Raku/roast that referenced this pull request Jul 30, 2020
Requires Raku/nqp#650 and rakudo/rakudo#3834 to pass.

I have removed trait `described` because the final implementation of
traits doesn't need covering two different trait routine signatures.

Renamed the role from `description` to `Description` because trait `is`
can't tell the difference between the trait and the role to pun because
of the same name used for both.

Because a trait is applied to a parametric role, not the role group,
test against the first group candidate.
It makes Attribute incompatible with Metamodel and other NQP classes via
a mixin.

`can` is to be avoided too because KnowHOW doesn't have it.
In a rare case the exception can be thrown for a KnowHOW type object or
instance. The problem is that method `methods` of KnowHOW returns not a
list of code objects but the method table itself in a hash form.
@vrurg vrurg merged commit d8f0507 into rakudo:master Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant