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

NQPRoutine sneaking into Perl 6 land through the Grammar class #4368

Open
p6rt opened this issue Jun 30, 2015 · 2 comments
Open

NQPRoutine sneaking into Perl 6 land through the Grammar class #4368

p6rt opened this issue Jun 30, 2015 · 2 comments

Comments

@p6rt
Copy link

p6rt commented Jun 30, 2015

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

Searchable as RT125518$

@p6rt
Copy link
Author

p6rt commented Jun 30, 2015

From @smls

Some of the methods of the Grammar class (such as FAILGOAL and !cursor_pos) are exposed to Perl 6 code as NQPRoutine objects, which throw LTA exceptions when introspected in the usual Perl 6 ways​:

  ➜ my $method = Grammar.^methods.first(*.name eq "!cursor_pos");
  cannot stringify this

  ➜ say $method.name;
  FAILGOAL

  ➜ say $method ~~ Regex;
  Invocant requires a 'Failure' instance, but a type object was passed. Did you forget a .new?

  ➜ say $method.WHAT;
  Method 'gist' not found for invocant of class 'NQPRoutine'

  ➜ say $method.WHAT.^name;
  NQPRoutine

This is a regression which caused the Grammar​::Debugger module to break, because its overloaded Grammar.find_method($obj, $name) does a $meth ~~ Regex check. (It now checks against $method.WHAT.^name first as a workaround.)

IRC comments​:

<jnthn> Yeah, that's the issue...the NQP object is sneaking into Perl 6 land.
<jnthn> We'd kinda like the introspection to work out there

<jnthn> they should in theory get exposed as a ForeignRoutine or so

@p6rt
Copy link
Author

p6rt commented Aug 2, 2016

From @smls

The bug still exists in​:

  This is Rakudo version 2016.07.1-97-g4ee1048 built on MoarVM version 2016.07-11-g11e02fe
  implementing Perl 6.c.

Except that now the fist line already throws an exception​:

  ➜ my $meth = Grammar.^methods.first({ .name eq "FAILGOAL" }).^name;
  X​::TypeCheck​::Binding exception produced no message
  in block <unit> at -e line 1

Apparently, .first can no longer deal with returning a NQPRoutine... :)
One can use .^find_method to confirm that the underlying problem is still that NQPRoutine's are being leaked​:

  ➜ say Grammar.^find_method("FAILGOAL").^name;
  NQPRoutine

@p6rt p6rt added the bootstrap label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant