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

Can't call .WHICH on Iteratable or Iterator due to accidental punning #4741

Closed
p6rt opened this issue Nov 10, 2015 · 4 comments
Closed

Can't call .WHICH on Iteratable or Iterator due to accidental punning #4741

p6rt opened this issue Nov 10, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Nov 10, 2015

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

Searchable as RT126606$

@p6rt
Copy link
Author

p6rt commented Nov 10, 2015

From @TimToady

21​:25 < TimToady> m​: say Iterable === Any
21​:25 <+camelia> rakudo-moar 2ad739​: OUTPUT«Method 'iterator' must be
implemented by Iterable because it is required by a role␤ in any
  compose_method_table at gen/moar/m-Metamodel.nqp​:2661␤ in
any apply at gen/moar/m-Metamodel.nqp​:2671␤ in any compose at
  gen/moar/m-Metamodel.nqp​:2807␤ in…»
21​:49 < TimToady> m​: sub foo(Iterable $s) {...}; say &foo.signature
21​:49 <+camelia> rakudo-moar 2ad739​: OUTPUT«Method 'iterator' must be
implemented by Iterable because it is required by a role␤ in any
  compose_method_table at gen/moar/m-Metamodel.nqp​:2661␤ in
any apply at gen/moar/m-Metamodel.nqp​:2671␤ in any compose at
  gen/moar/m-Metamodel.nqp​:2807␤ in…»
21​:50 < TimToady> that tries to call Iterable.WHICH, and that forces role
punning, which doesn't work here
21​:50 < TimToady> m​: say Iterable.foo
21​:50 <+camelia> rakudo-moar 2ad739​: OUTPUT«Method 'iterator' must be
implemented by Iterable because it is required by a role␤ in any
  compose_method_table at gen/moar/m-Metamodel.nqp​:2661␤ in
any apply at gen/moar/m-Metamodel.nqp​:2671␤ in any compose at
  gen/moar/m-Metamodel.nqp​:2807␤ in…»
21​:50 < TimToady> doesn't matter which method you call on it

@p6rt
Copy link
Author

p6rt commented Dec 12, 2015

From @jnthn

On Mon Nov 09 22​:21​:58 2015, larry wrote​:

21​:25 < TimToady> m​: say Iterable === Any
21​:25 <+camelia> rakudo-moar 2ad739​: OUTPUT«Method 'iterator' must be
implemented by Iterable because it is required by a role␤ in any
compose_method_table at gen/moar/m-Metamodel.nqp​:2661␤ in
any apply at gen/moar/m-Metamodel.nqp​:2671␤ in any compose at
gen/moar/m-Metamodel.nqp​:2807␤ in…»
21​:49 < TimToady> m​: sub foo(Iterable $s) {...}; say &foo.signature
21​:49 <+camelia> rakudo-moar 2ad739​: OUTPUT«Method 'iterator' must be
implemented by Iterable because it is required by a role␤ in any
compose_method_table at gen/moar/m-Metamodel.nqp​:2661␤ in
any apply at gen/moar/m-Metamodel.nqp​:2671␤ in any compose at
gen/moar/m-Metamodel.nqp​:2807␤ in…»
21​:50 < TimToady> that tries to call Iterable.WHICH, and that forces role
punning, which doesn't work here
21​:50 < TimToady> m​: say Iterable.foo
21​:50 <+camelia> rakudo-moar 2ad739​: OUTPUT«Method 'iterator' must be
implemented by Iterable because it is required by a role␤ in any
compose_method_table at gen/moar/m-Metamodel.nqp​:2661␤ in
any apply at gen/moar/m-Metamodel.nqp​:2671␤ in any compose at
gen/moar/m-Metamodel.nqp​:2807␤ in…»
21​:50 < TimToady> doesn't matter which method you call on it

Well, trying to pun the role is the correct behavior on method calls on it, in general. We maintained a rather short list of methods that did not trigger punning; I've just expanded it quite a bit to include things people are likely to not want it to pun on, including .WHICH. The behavior for calling .foo is correct​: it should try to pun and fail due to the missing method.

Tests in S14-roles/stubs.t.

@p6rt
Copy link
Author

p6rt commented Dec 12, 2015

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

@p6rt
Copy link
Author

p6rt commented Dec 12, 2015

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

@p6rt p6rt closed this as completed Dec 12, 2015
@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