diff --git a/src/core/Match.pm b/src/core/Match.pm index 451cc7db988..630509f08e0 100644 --- a/src/core/Match.pm +++ b/src/core/Match.pm @@ -1,4 +1,4 @@ -class Match is Regex::Match is Cool does Associative { +class Match is Regex::Match is Cool does Positional does Associative { method ast() { my $x = self.Regex::Match::ast; pir::isa__IPs($x, 'Undef') ?? Any !! $x; @@ -8,7 +8,8 @@ class Match is Regex::Match is Cool does Associative { ~self.Regex::Match::Str; } - multi method postcircumfix:<{ }>($key) { + + method at_key($key) { Q:PIR { $P0 = find_lex 'self' $P1 = find_lex '$key' @@ -21,17 +22,10 @@ class Match is Regex::Match is Cool does Associative { } } - # We shouldn't need to provide this -- we should be able to - # simply write "does Positional" in the class declaration - # and it would provide us the postcircumfix:<[ ]> methods - # for free. But there seems to be a bug or problem in the - # role composer that prevents us from having both "does Positional" - # and "does Associative" in the class declaration, so we'll - # provide the simple .[] for now. - multi method postcircumfix:<[ ]>(Int $key) { + method at_pos($pos) { Q:PIR { $P0 = find_lex 'self' - $P1 = find_lex '$key' + $P1 = find_lex '$pos' $I1 = $P1 %r = $P0[$I1] unless null %r goto done @@ -42,6 +36,8 @@ class Match is Regex::Match is Cool does Associative { } } + method of() { Mu } + multi method hash() { # nextsame() dies here with 'Null PMC access in clone()' CREATE_HASH_FROM_LOW_LEVEL(self.Regex::Match::hash);