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

Some Method objects use wrong .gist method #6545

Open
p6rt opened this issue Sep 23, 2017 · 1 comment
Open

Some Method objects use wrong .gist method #6545

p6rt opened this issue Sep 23, 2017 · 1 comment
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 23, 2017

Migrated from rt.perl.org#132149 (status was 'new')

Searchable as RT132149$

@p6rt
Copy link
Author

p6rt commented Sep 23, 2017

From @zoffixznet

Method objects have their own `.gist` method[^1] that just print `.name`. However, under some
circumstances, that method is lost, and `Mu​::gist` is used instead​:

  <Zoffix__> m​: <z>.comb.^methods.grep(*.name eq 'eager').say
  <camelia> rakudo-moar 7af339​: OUTPUT​: «(Method+{<anon|61058032>}.new)␤»

I tried to fix it and failed, but found some facts about the bug that might give a hint​:

*) The problematic methods has `is nodal` trait on them (which mixes in a role), but NOT all nodal
  methods have this issue
*) (90% sure this is what happened) If you add an only `method z is nodal {}` to src/core/Any.pm, the bug doesn't appear
*) If you add a `multi method z is nodal {}` to src/core/Any.pm the bug occurs
*) If you do the same thing with a regular class, it doesn't happen. BTW​: `Any` is augmented in core
*) .file on the method gives src/core/Method.pm. However, if you modify Mu.gist to append some string,
  you'll see that it's Mu's method that gets called.

  <Zoffix__> m​: my $m = <z>.comb.^methods.grep(*.name eq 'eager').head; dd $m.^lookup('gist').cando(\($m)).head.file
  <camelia> rakudo-moar 7af339​: OUTPUT​: «"SETTING​::src/core/Method.pm"␤»

*) Even if you make Method.gist an `only` method, the Mu​::gist one is still the one that gets called
*) If you implement only or multi method `gist` in the role that `is nodal` mixed in[^2], trying to
  call .gist on the buggy method gives "Cannot invoke this object (REPR​: Null; VMNull)"

[1] https://github.com/rakudo/rakudo/blob/045ef448b62c045630abb8e167cc45d1f9fe6902/src/core/Method.pm#L4
[2] https://github.com/rakudo/rakudo/blob/7af339b91d2a56a4a4eb065952cd548c188bd124/src/core/traits.pm#L357

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