Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop with |"a".."z" #5051

Closed
p6rt opened this issue Jan 15, 2016 · 5 comments
Closed

Infinite loop with |"a".."z" #5051

p6rt opened this issue Jan 15, 2016 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jan 15, 2016

Migrated from rt.perl.org#127279 (status was 'resolved')

Searchable as RT127279$

@p6rt
Copy link
Author

p6rt commented Jan 15, 2016

From @zoffixznet

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

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

From @skids

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​:

rakudo/rakudo#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.

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 7, 2017

From @skids

On Fri, 06 Oct 2017 19​:32​:17 -0700, bri@​abrij.org wrote​:

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​:

rakudo/rakudo#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?

@p6rt
Copy link
Author

p6rt commented Dec 12, 2017

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 12, 2017
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant