Skip Menu |
Report information
Id: 127279
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: cpan [at] zoffix.com
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] Infinite loop with |"a".."z"
Download (untitled) / with headers
text/plain 1.1k
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
Download (untitled) / with headers
text/plain 2.2k
On Fri, 15 Jan 2016 10:24:16 -0800, cpan@zoffix.com wrote: Show quoted text
> 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.
Download (untitled) / with headers
text/plain 2.5k
On Fri, 06 Oct 2017 19:32:17 -0700, bri@abrij.org wrote: Show quoted text
> On Fri, 15 Jan 2016 10:24:16 -0800, cpan@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.
OK, PR merged in rakudo cb9d2e040 Tests in roast 6e9bab5de These are just worries, not errors, but good enough?


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

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