Am 08.09.2010 14:53, schrieb Mark Biggar:
On 9/7/2010 12:36 PM, Aaron Sherman wrote:
Oddly, these two expressions have the same output:

for 0 ...^ (3+4) -> $i { say $i }
for 0 ...^ 7 -> $i { say $i }

But this one prints the numbers 0 through 7 instead of leaving off the
last
number:

for 0 ...^ 3+4 -> $i { say $i }

It does the same with or without the ^ so it's like it's just ignoring
the ^
in the case above.

The parser obviously binds ^ tighter than + which binds tighter than ...
so this parses as
for 0 ...((^ 3)+4) -> $i { say $i }
^3 (which is the same as 0...2) numifies as its length 3 so that makes
this the same as
for 0 ...7 -> $i { say $i }
so as long as those are the right precedence levels for those operators
this is not a bug

Since ...^ is supposed to be an operator on its own, parsing it as anything else is a bug. But fixed in rakudo HEAD.

Cheers,
Moritz

Reply via email to