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

accessor method does not count as implementation of required method #2914

Closed
p6rt opened this issue Oct 10, 2012 · 5 comments
Closed

accessor method does not count as implementation of required method #2914

p6rt opened this issue Oct 10, 2012 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 10, 2012

Migrated from rt.perl.org#115212 (status was 'resolved')

Searchable as RT115212$

@p6rt
Copy link
Author

p6rt commented Oct 10, 2012

From @edwinst

When a role requires a method to be implented, rakudo does not consider accessor methods that implement the required method.

Also the error message is LTA as it would be nice to know *which* role requires the method.

Example​:

$ cat t2.pl
role Wanter {
  method foo { ... }
  method bar { self.foo + 1 }
}

class Giver does Wanter {
  has $.foo;
  # This line should not be necessary​: method foo { $!foo }
}

say Giver.new(​:foo(41)).bar;

$ ./perl6 t2.pl
===SORRY!===
Method 'foo' must be implemented by Giver because it is required by a role

$ ./perl6 --version
This is perl6 version 2012.09.1-7-gfb11f13 built on parrot 4.4.0 revision RELEASE_4_4_0

IRC log about this topic​:
http://irclog.perlgeek.de/perl6/2012-10-09#i_6047393

20​:52 _edwin when I change to "role FPS" I get an error that ExplicitFPS does not implement the method coeffs
20​:53 it seems the implicit accessor method does not count towards the role
20​:53 colomon _edwin​: you can easily explicitly define it, obviously, but I am surprised, I admit.
20​:53 _edwin is it a bug or a feature? :}
20​:53 jnthn Well, things at composition time have to happen in some order.
20​:54 colomon _edwin​: I think you need jnthn for that question. :)
20​:54 jnthn At the moment roles are composed *then* we compose attributes.
20​:55 iirc, it has to be that way because roles can contribute attributes that need accessors generating too
20​:55 Is the issue that the role has a required method?
20​:55 _edwin yes
20​:55 jnthn Yeah...
20​:55 I don't think we can fix that by swapping around the order compose does things.
20​:55 But I agree it's icky
20​:56 _edwin and the derived class just "has @​.coeffs" and not "method coeffs { @​.coeffs }"
20​:56 jnthn Yeah
20​:56 I suspect it's possible for the role applier to give back a list of things that are required
20​:56 But not complain about them immediately
20​:56 And then we check if they're there later

20​:58 jnthn _edwin​: I think you want method coeffs { @​!coeffs }
20​:58 _edwin​: I think the requirement/accessor thing should really be fixed. Please file a ticket.

@p6rt
Copy link
Author

p6rt commented Oct 10, 2012

From sohtil@gmail.com

spectest added​:

commit 920c5be01d5d4a725226cf49646cf37475e4b84e
Author​: Edwin Steiner <edwin.steiner@​gmx.net>
Date​: Wed Oct 10 20​:38​:09 2012 +0200

  Add test for RT #​115212​: [BUG] accessor method does not count as implementation of
required method.

diff --git a/S14-roles/stubs.t b/S14-roles/stubs.t

@p6rt
Copy link
Author

p6rt commented Oct 10, 2012

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

@p6rt
Copy link
Author

p6rt commented Oct 13, 2012

From @moritz

Fixed in commit e2eb219 and test unfudged. Thanks!

@p6rt
Copy link
Author

p6rt commented Oct 13, 2012

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 13, 2012
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant