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

.skip on a sequence starting with a Slip, returns a corrupted Seq #6529

Closed
p6rt opened this issue Sep 17, 2017 · 5 comments
Closed

.skip on a sequence starting with a Slip, returns a corrupted Seq #6529

p6rt opened this issue Sep 17, 2017 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 17, 2017

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

Searchable as RT132109$

@p6rt
Copy link
Author

p6rt commented Sep 17, 2017

From @smls

When calling `.skip` on a list which contains a `Slip` at the start, the
resulting `Seq` behaves in some cases as if *all* elements from that
`Slip` were skipped (instead of just the first one)​:

  say (<a b c>, <d e>).map(|*).skip.perl; # ("d", "e").Seq
  say (<a b c>, <d e>).map(|*).skip.eager.perl; # ("d", "e").Seq
  say (<a b c>, <d e>).map(|*).skip.eager.gist; # (d e)
  say (<a b c>, <d e>).map(|*).skip.eager.join; # de
  say (<a b c>, <d e>).map(|*).skip.cache.perl; # ("d", "e")
  say (<a b c>, <d e>).map(|*).skip.cache.join; # de
  say (<a b c>, <d e>).map(|*).skip.[*].gist; # (d e)

But it depends on how the returned `Seq` is iterated. In the following
cases it behaves correctly​:

  say (<a b c>, <d e>).map(|*).skip.gist; # (b c d e)
  say (<a b c>, <d e>).map(|*).skip.join; # bcde
  say (<a b c>, <d e>).map(|*).skip.cache.gist; # (b c d e)
  say (<a b c>, <d e>).map(|*).skip.[0..*].gist; # (b c d e)
  say (<a b c>, <d e>).map(|*).skip.iterator.pull-one; # b

It looks like¹ this bug has existed ever since the `.skip` method was
implemented² in January 2017.


[1] https://gist.github.com/Whateverable/973c1b6cb09af28a2249b4ba33165885
[2] rakudo/rakudo@8a6bfc6


This is Rakudo version 2017.08-156-ge6a695b27 built on MoarVM version
2017.08.1-171-gcf95892e
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Sep 17, 2017

From @lizmat

On 17 Sep 2017, at 07​:29, Sam S. (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Sam S.
# Please include the string​: [perl #​132109]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=132109 >

When calling `.skip` on a list which contains a `Slip` at the start, the
resulting `Seq` behaves in some cases as if *all* elements from that
`Slip` were skipped (instead of just the first one)​:

say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.perl;        \# \("d", "e"\)\.Seq
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.eager\.perl;  \# \("d", "e"\)\.Seq
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.eager\.gist;  \# \(d e\)
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.eager\.join;  \# de
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.cache\.perl;  \# \("d", "e"\)
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.cache\.join;  \# de
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.\[\*\]\.gist;    \# \(d e\)

But it depends on how the returned `Seq` is iterated. In the following
cases it behaves correctly​:

say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.gist;               \# \(b c d e\)
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.join;               \# bcde
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.cache\.gist;         \# \(b c d e\)
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.\[0\.\.\*\]\.gist;        \# \(b c d e\)
say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.iterator\.pull\-one;  \# b

It looks like¹ this bug has existed ever since the `.skip` method was
implemented² in January 2017.

---
[1] https://gist.github.com/Whateverable/973c1b6cb09af28a2249b4ba33165885
[2] rakudo/rakudo@8a6bfc6

I think he problem here is in Seq.cache. Investigating...

@p6rt
Copy link
Author

p6rt commented Sep 17, 2017

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

@p6rt
Copy link
Author

p6rt commented Sep 30, 2017

From @zoffixznet

On Sat, 16 Sep 2017 22​:29​:57 -0700, smls75@​gmail.com wrote​:

When calling `.skip` on a list which contains a `Slip` at the start, the
resulting `Seq` behaves in some cases as if *all* elements from that
`Slip` were skipped (instead of just the first one)​:

 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.perl;        \# \("d", "e"\)\.Seq
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.eager\.perl;  \# \("d", "e"\)\.Seq
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.eager\.gist;  \# \(d e\)
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.eager\.join;  \# de
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.cache\.perl;  \# \("d", "e"\)
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.cache\.join;  \# de
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.\[\*\]\.gist;    \# \(d e\)

But it depends on how the returned `Seq` is iterated. In the following
cases it behaves correctly​:

 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.gist;               \# \(b c d e\)
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.join;               \# bcde
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.cache\.gist;         \# \(b c d e\)
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.\[0\.\.\*\]\.gist;        \# \(b c d e\)
 say \(\<a b c>, \<d e>\)\.map\(|\*\)\.skip\.iterator\.pull\-one;  \# b

It looks like¹ this bug has existed ever since the `.skip` method was
implemented² in January 2017.

---
[1] https://gist.github.com/Whateverable/973c1b6cb09af28a2249b4ba33165885
[2] rakudo/rakudo@8a6bfc6

---
This is Rakudo version 2017.08-156-ge6a695b27 built on MoarVM version
2017.08.1-171-gcf95892e
implementing Perl 6.c.

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@41896b7bbf9fe5a
Test​: Raku/roast@2e23965fa1180b732

@p6rt p6rt closed this as completed Sep 30, 2017
@p6rt
Copy link
Author

p6rt commented Sep 30, 2017

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

@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