On Fri, 15 Jan 2016 10:24:16 -0800, c...@zoffix.com wrote:
> The slip (|) before a range has higher precedence and it interprets
> the starting point of the range as a single-item list. This leads to
> two types of bugs, and both situations should likely be error
> messages:
> 
> 1) Infinite loop when range contains letters, as the range starts from
> 1 and tries to reach the second letter by increasing a number:
> 
> <ZoffixW> m: .say for |"g".."z";
> <camelia> rakudo-moar 3259ba:
> OUTPUT«(timeout)1␤2␤3␤4␤5␤6␤7␤8␤9␤10␤11␤12␤13␤14␤15␤16␤17␤18␤19␤20␤21␤22␤23␤24␤25␤26␤27␤28␤29␤30␤31␤32␤33␤34␤35␤36␤37␤38␤39␤40␤41␤42␤43␤44␤45␤46␤47␤48␤49␤50␤51␤5…»
> 
> 2) Incorrect range is produced when numbers are used for the range.
> It'll always start at 1 and proceed until the end number:
> <ZoffixW> m: .say for |10..20
> <camelia> rakudo-moar 3259ba:
> OUTPUT«1␤2␤3␤4␤5␤6␤7␤8␤9␤10␤11␤12␤13␤14␤15␤16␤17␤18␤19␤20␤»
> <ZoffixW> m: .say for |10..5
> <camelia> rakudo-moar 3259ba: OUTPUT«1␤2␤3␤4␤5␤»
> 
> Relevant IRC conversation: http://irclog.perlgeek.de/perl6/2016-01-
> 15#i_11894289

I submitted:

https://github.com/rakudo/rakudo/pull/1182

...which warns on these:

$ perl6 -e 'say |4..5'
Potential difficulties:
    To apply a Slip flattener to a range, parenthesize the whole range.
    (Or parenthesize the whole endpoint expression, if you meant that.)
    at -e:1
    ------> say ⏏|4..5
1..5
$ perl6 -e 'say ~4..5'
Potential difficulties:
    To stringify a range, parenthesize the whole range.
    (Or parenthesize the whole endpoint expression, if you meant that.)
    at -e:1
    ------> say ⏏~4..5
"4"..5
$ perl6 -e 'say |4 R.. 5'
Potential difficulties:
    To apply a Slip flattener to a range, parenthesize the whole range.
    (Or parenthesize the whole endpoint expression, if you meant that.)
    at -e:1
    ------> say ⏏|4 R.. 5
5..1
$ perl6 -e 'say ~4 R.. 5'
Potential difficulties:
    To stringify a range, parenthesize the whole range.
    (Or parenthesize the whole endpoint expression, if you meant that.)
    at -e:1
    ------> say ⏏~4 R.. 5
5..4

(don't know why that last one "works", but still worth warning.)

It also handles all the ^..^ variants.

Reply via email to