A difference between Unicode and ASCII operators

Fernando Santagata

I found out that Unicode and ASCII operators sometimes work differently when quote-interpolated.

Consider this:

$ perl6 -e'my $a = BagHash.new: <a a a a b b b c c c c c d>;for $a.keys -> $k { say "$k => $a<<$k>>" }'

d => 1
b => 3
c => 5
a => 4

and this:

$ perl6 -e'my $a = BagHash.new: <a a a a b b b c c c c c d>;for $a.keys -> $k { say "$k => $a«$k»" }'

c => c(5) a(4) b(3) d«c»
a => c(5) a(4) b(3) d«a»
b => c(5) a(4) b(3) d«b»
d => c(5) a(4) b(3) d«d»

But this works even when using an Unicode operator:

$ perl6 -e'my $a = BagHash.new: <a a a a b b b c c c c c d>;for $a.keys -> $k { say "$k => {$a«$k»}" }'
d => 1
b => 3
a => 4
c => 5

Is this a bug, or there's an explanation I can't see?

Valle Lukas

Seems to be fixed with commit 2835 from MasterDuke17:

  sub bracket_ending($matches) {
      my $check     := $matches[+$matches - 1];
      my str $str   := $check.Str;
      my $last  := nqp::substr($str, nqp::chars($check) - 1, 1);
-     $last eq ')' || $last eq '}' || $last eq ']' || $last eq '>'
+     $last eq ')' || $last eq '}' || $last eq ']' || $last eq '>' || $last eq '»'
  }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章