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

Make .WHY on role group delegate to default role #3549

Merged
merged 3 commits into from Jan 6, 2022
Merged

Conversation

jnthn
Copy link
Member

@jnthn jnthn commented Mar 13, 2020

Roles have a two-level structure: the role name is a parametric role
group, which in turns contains the parametric role. In the case of there
being many roles of the same short name, they are within the one group.
Declarator docs correctly attach to the parametric role. However, that
means .WHY on the group doesn't actually result in those docs. You have
to extract the candidate from the group.

In many cases, however, we people ain't using parametric roles, and we
make many meta-operations delegate to the single or unsignatured role
candidate, if any. We do not currently do this for .WHY. This commit
makes us do so, BUT it turns out there are 3 current spectests that will
fail because they explicitly expect that not to happen. Thus, we need to
make a decision over whether we want this change.

Relates to #3521.

@vrurg
Copy link
Member

vrurg commented Mar 13, 2020

My sense of DWIM likes the change.

With regard to spectest: this can be 6.e+ specific change. Considering that candidates on a group might be of different language revisions, it would make sense to test for revision of the default candidate.

@lizmat lizmat added the 6.e Related to the next 6.e language release label Jul 20, 2020
@niner
Copy link
Collaborator

niner commented Sep 5, 2020

The 3 failing spec tests all have the same description "Role group's WHY should not be defined" and were committed by the @hoelzro around the same time. They seem to be testing the same thing in different settings (leading and trailing docs). I'm pretty sure they result from this single example in the speculations:

 #| Attaches to the specific parameterized role, rather than the role group itself
    role R[::T] {}
    role R {}

This is what the tests were meant to establish. Note that this one sentence does not actually prohibit the role group from delegating to the default role. It merely requires that individual roles can be documented. This commit does not violate that requirement. It just extends availability of the default role's docs to the role group which as the linked issue makes pretty clear is what people expect (because they usually don't think in terms of role groups).

I think the failing spec tests are simply overly specific and adapting them so this can be merged will do much more good than harm. I only see potential for a little bit of confusion of tools, but since @jnthn is directly involved with the current major consumer (Comma-IDE), he'll know best about this anyway. Even if there is any confusion at all, tools would have to be adapted anyway to deal with the next language version and then maybe even differentiate between versions. So it's not just us who'd have to carry code to hide this feature in old versions, but those other tools as well. I'm pretty sure that's not worth the hassle and it's better to merge this as-is.

@lizmat
Copy link
Contributor

lizmat commented Jan 5, 2022

Fixed the conflict, is this ready to be merged?

@lizmat
Copy link
Contributor

lizmat commented Jan 5, 2022

@vrurg @jnthn This is NOT ready to be merged, as there appears to be two interpretations of the !get_default_candidate method, and there are calls in the code to both interpretations.

@lizmat lizmat marked this pull request as draft January 5, 2022 20:39
@vrurg
Copy link
Member

vrurg commented Jan 5, 2022

@lizmat There is no contradiction, just an overlook. :) The first one is apparently a leftover. Lines 220 and 227 are to be fixed. I can get it done if @jnthn doesn't mind.

@jnthn
Copy link
Member Author

jnthn commented Jan 5, 2022

@vrurg Sure, go for it. 🙏

jnthn and others added 3 commits January 5, 2022 18:07
Roles have a two-level structure: the role name is a parametric role
group, which in turns contains the parametric role. In the case of there
being many roles of the same short name, they are within the one group.
Declarator docs correctly attach to the parametric role. However, that
means .WHY on the group doesn't actually result in those docs. You have
to extract the candidate from the group.

In many cases, however, we people ain't using parametric roles, and we
make many meta-operations delegate to the single or unsignatured role
candidate, if any. We do not currently do this for .WHY. This commit
makes us do so, BUT it turns out there are 3 current spectests that will
fail because they explicitly expect that not to happen. Thus, we need to
make a decision over whether we want this change.

Relates to #3521.
- Remove `Perl6::Metamodel::Documenting` from consumed roles
- Fully implement `WHY`, `set_why`
- Make `set_why` throw `X::Role::Group::Documenting` as a safety measure

I deliberately don't delegate `set_why` in order to avoid accidental
overriding of parametric role documentation. It doesn't and must not
happen in Rakudo implementation anyway.
Because signature is a local scope from documentation point of view.

Fixes documenting of parametric role:

    role R[::T] {
        #= this now belongs to the role, not to the parameter T
    }

And makes one spec TODO passing.
vrurg added a commit to Raku/roast that referenced this pull request Jan 6, 2022
This required to remove tests which were testing for `Role.WHY`
returning `Nil`. But as was suggested in this comment:

rakudo/rakudo#3549 (comment)

the tests were needed to ensure that a documentation comment is attached
to a particular parametric role, not to its group. But since
rakudo/rakudo#3549 makes `.WHY` delegate to the default candidate, these
tests doesn't make sense anymore. Instead why-both.t now makes sure what
we get from a role group is the same object we get from the default
candidate.

Alongside with the essential changes, also unified all tests with regard
to use of idential test assertion subs. They all now are `subtest`
based.
vrurg added a commit to Raku/roast that referenced this pull request Jan 6, 2022
It is passing since rakudo/rakudo#3549
@vrurg
Copy link
Member

vrurg commented Jan 6, 2022

I couldn't stop on just fixing the methods...

Since a role group is not documentable, I removed the corresponding role from it. set_why will now throw because I consider delegating it potentially unsafe. This breaks none of Rakudo or spectests.

Spectests were adjusted to the new behavior in Raku/roast#783 by removing the requirement of RoleGroup.WHY to return Nil, according to @niner comment above. Instead I made why-both.t making sure that group's WHY is the same, as its default candidate. This required me to be explicit in the order of declaration of parametric roles and, basically, rely on the internal implementation. Doesn't feel good to me. Perhaps we should make !get_default_candidate public and rename it to default-candidate?

Otherwise PR is ready for merge. The failure of Lin_MVM_spec CI can be ignored, it is the only one ran against the specs, which are not ready yet.

@vrurg vrurg marked this pull request as ready for review January 6, 2022 14:11
@vrurg vrurg merged commit f77fda7 into master Jan 6, 2022
@Altai-man Altai-man deleted the WHY-on-role-group branch January 7, 2022 11:31
jdv pushed a commit to Raku/roast that referenced this pull request Feb 11, 2022
This required to remove tests which were testing for `Role.WHY`
returning `Nil`. But as was suggested in this comment:

rakudo/rakudo#3549 (comment)

the tests were needed to ensure that a documentation comment is attached
to a particular parametric role, not to its group. But since
rakudo/rakudo#3549 makes `.WHY` delegate to the default candidate, these
tests doesn't make sense anymore. Instead why-both.t now makes sure what
we get from a role group is the same object we get from the default
candidate.

Alongside with the essential changes, also unified all tests with regard
to use of idential test assertion subs. They all now are `subtest`
based.
jdv pushed a commit to Raku/roast that referenced this pull request Feb 11, 2022
This required to remove tests which were testing for `Role.WHY`
returning `Nil`. But as was suggested in this comment:

rakudo/rakudo#3549 (comment)

the tests were needed to ensure that a documentation comment is attached
to a particular parametric role, not to its group. But since
rakudo/rakudo#3549 makes `.WHY` delegate to the default candidate, these
tests doesn't make sense anymore. Instead why-both.t now makes sure what
we get from a role group is the same object we get from the default
candidate.

Alongside with the essential changes, also unified all tests with regard
to use of idential test assertion subs. They all now are `subtest`
based.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.e Related to the next 6.e language release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants