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

The object coming back from a regex match is not of type Match in Rakudo #1599

Closed
p6rt opened this issue Mar 9, 2010 · 6 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 9, 2010

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

Searchable as RT73462$

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

From @masak

<moritz_> rakudo​: say ('a' ~~ /a/).WHAT
<p6eval> rakudo 16efb6​: OUTPUT«Regex​::Match()␤»
<moritz_> rakudo​: say ('a' ~~ /a/) ~~ Match
<p6eval> rakudo 16efb6​: OUTPUT«Could not find non-existent sub &Match [...]
* masak submits rakudobug

The spec is pretty clear that it should be Match.

@p6rt
Copy link
Author

p6rt commented Apr 4, 2010

From @moritz

This has been discussed on IRC, but for the record I'll dump my thoughts
and current progress here.

First the matter is much deeper than simply a wrong type name​: All of
the objects accessible form the current Match object are really parrot
types, so for example .kv won't work on the hashes, .sort will call
parrot's built-in sort, and not the Perl 6 (much more magical) sort etc.

The correct solution seems to be to let NQP-RX build Perl 6 match
objects, not NQP/parrot match objects.

To achieve that more easily, I created the 'refactor_mob_generation'
branch of NQP-rx. It aims at detangling the match object generation
logic from the actually process of creating/instantiating the match
object. In this branch, NQP-rx has the type object of a Match class, and
calls the .create method on it, along with various arguments (original
string, position, match length, named and positional captures) and lets
the type object take care of the actual instantiation.

This has the advantage of better encapsulation, but the disadvantage of
creating more objects​: instead of writing directly to the Match object,
now arrays and hashes are created first, which in turn are then copied
onto the Match object.

So there are basically three things left do​:

1) wait for Patrick to review the branch, and if he's agreeable, merge it
2) Implement a means to pass a different type object to NQP-rx
3) Implement a pure Perl 6 Match object, and hook it into NQP-rx

Once done, this will fix both this ticket and probably RT #​70003.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Apr 4, 2010

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

@p6rt
Copy link
Author

p6rt commented May 28, 2010

From @ajs

It sounds like this bug is going to address what I care about, but let me
add a test case, just for clarity​:

ajs​: rakudo​: "abc" ~~ /[ 'a' $&lt;b&gt; = (b) ]?/; $/<b>.WHAT;
p6eval​: rakudo c5fdb1​: OUTPUT«Method 'WHAT' not found for invocant of
class 'ResizablePMCArray'␤current instr.​: '_block14' pc 29 (EVAL_1​:0)␤»

@p6rt
Copy link
Author

p6rt commented May 30, 2010

From @moritz

fixed, and unfudged several tests for it.

@p6rt
Copy link
Author

p6rt commented May 30, 2010

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

@p6rt p6rt closed this as completed May 30, 2010
@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