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

LTA: roles enforce method signatures only with multi methods #2384

Open
zoffixznet opened this issue Oct 17, 2018 · 1 comment
Open

LTA: roles enforce method signatures only with multi methods #2384

zoffixznet opened this issue Oct 17, 2018 · 1 comment
Labels
consistency LTA Less Than Awesome; typically an error message that could be better roles

Comments

@zoffixznet
Copy link
Contributor

From https://stackoverflow.com/questions/52861619/are-typed-signatures-for-stubbed-methods-not-enforced-in-roles-for-perl6

Looks like only methods don't care if signatures match:

$ perl6 -e 'role Foo { method bar (Int) { … } }; class Bar does Foo { method bar(Str) { } }'
$

Yet, the functionality of enforcing correct signatures is available if you swap to using multi methods:

$ perl6 -e 'role Foo { multi method bar (Int) { … } }; class Bar does Foo { multi method bar(Str) { } }'
===SORRY!=== Error while compiling -e
Multi method 'bar' with signature :(Bar: Int $, *%_) must be implemented by Bar because it is required by a role
at -e:1

$ perl6 -v
This is Rakudo version 2018.06-146-g1b3dd35 built on MoarVM version 2018.06-141-gcae4731
implementing Perl 6.c.

IMO, only methods should enforce signatures too.

@zoffixznet zoffixznet added LTA Less Than Awesome; typically an error message that could be better consistency labels Oct 17, 2018
@jnthn
Copy link
Member

jnthn commented Oct 17, 2018

Seems like a reasonable thing for the 6.e wish list (I think it'll be too much of a breaking change to do it without a language version change).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consistency LTA Less Than Awesome; typically an error message that could be better roles
Projects
None yet
Development

No branches or pull requests

3 participants