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

wrong behaviour of chained sequence operators #3596

Closed
p6rt opened this issue Nov 29, 2014 · 7 comments
Closed

wrong behaviour of chained sequence operators #3596

p6rt opened this issue Nov 29, 2014 · 7 comments

Comments

@p6rt
Copy link

p6rt commented Nov 29, 2014

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

Searchable as RT123329$

@p6rt
Copy link
Author

p6rt commented Nov 29, 2014

From @usev6

According to S03 it is possible to chain sequence operators. There are some tests in S03-sequence/misc.t and there is also the following example in S03​:

$ perl6 -e 'say 1, *+1 ... { $_ == 9 }, 10, *+10 ... { $_ == 90 }, 100, *+100 ... { $_ == 900 }'
use of uninitialized value of type Nil in numeric context in block <unit> at -e​:1

1 2 3 4 5 6 7 8 False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False ...

That's not what was expected (and described in S03). I tried to golf the problem a bit and found the following​:

$ perl6 -e 'say 1, 2 ... 4, 6 ... 10' ## seems to work
1 2 3 4 6 8 10

$ perl6 -e 'say 1, 2 ... 4, 6 ... 10, 12' ## oops; also stops with 10
1 2 3 4 6 8 10

$ perl6-m -e 'say 1, 2 ... * > 3, 6' ## seems to work
1 2 3 4 6

$ perl6-m -e 'say 1, 2 ... * > 3, 6 ... 10' ## dies
Too few positionals passed; expected 1 argument but got 0
  in block <unit> at -e​:1

$ perl6-m -e 'say 1, 2 ... { $_ > 3 }, 6' ## works
1 2 3 4 6
perl6-m -e 'say 1, 2 ... { $_ > 3 }, 6 ... 10' ## doesn't die, but ...
use of uninitialized value of type Nil in numeric context in block <unit> at -e​:1

1 2 3 False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False False ...

I vaguely suspect that during evaluation of the sequences after one point the wrong values (no values at all) are passed to a smartmatch operation.

@p6rt
Copy link
Author

p6rt commented Dec 3, 2014

From @usev6

I added tests for this ticket to S03-sequence/misc.t with commit Raku/roast@1db2856082

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 3, 2014

From @usev6

I added tests for this ticket to S03-sequence/misc.t with commit Raku/roast@1db2856082

@p6rt
Copy link
Author

p6rt commented Dec 3, 2014

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

From @usev6

This works now (same output on Moar, Parrot and JVM)​:

$ perl6 -e 'say 1, *+1 ... { $_ == 9 }, 10, *+10 ... { $_ == 90 }, 100, *+100 ... { $_ == 900 }'
1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 200 300 400 500 600 700 800 900

$ perl6 -e 'say 1, 2 ... 4, 6 ... 10, 12'
1 2 3 4 6 8 10 12

$ perl6-m -e 'say 1, 2 ... * > 3, 6 ... 10'
1 2 3 4 6 8 10

$ perl6-m -e 'say 1, 2 ... { $_ > 3 }, 6 ... 10'
1 2 3 4 6 8 10

The corresponding tests in S03-sequence/misc.t are passing. I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

From @usev6

This works now (same output on Moar, Parrot and JVM)​:

$ perl6 -e 'say 1, *+1 ... { $_ == 9 }, 10, *+10 ... { $_ == 90 }, 100, *+100 ... { $_ == 900 }'
1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90 100 200 300 400 500 600 700 800 900

$ perl6 -e 'say 1, 2 ... 4, 6 ... 10, 12'
1 2 3 4 6 8 10 12

$ perl6-m -e 'say 1, 2 ... * > 3, 6 ... 10'
1 2 3 4 6 8 10

$ perl6-m -e 'say 1, 2 ... { $_ > 3 }, 6 ... 10'
1 2 3 4 6 8 10

The corresponding tests in S03-sequence/misc.t are passing. I'm closing this ticket now.

@p6rt p6rt closed this as completed Dec 11, 2014
@p6rt
Copy link
Author

p6rt commented Dec 11, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant