Skip Menu |

Subject: [BUG] The object coming back from a regex match is not of type Match in Rakudo
Date: Tue, 9 Mar 2010 14:15:18 +0100
To: rakudobug [...]
From: Carl Mäsak <cmasak [...]>
Download (untitled) / with headers
text/plain 290b
<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.
RT-Send-CC: perl6-compiler [...], pmichaud [...]
Download (untitled) / with headers
text/plain 1.5k
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
Download (untitled) / with headers
text/plain 318b
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' $<b> = (b) ]?/; $/<b>.WHAT; p6eval: rakudo c5fdb1: OUTPUT«Method 'WHAT' not found for invocant of class 'ResizablePMCArray'␤current instr.: '_block14' pc 29 (EVAL_1:0)␤»
fixed, and unfudged several tests for it.

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at