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

Set.new erroneously flattens arrays in Rakudo #2997

Closed
p6rt opened this issue Dec 14, 2012 · 4 comments
Closed

Set.new erroneously flattens arrays in Rakudo #2997

p6rt opened this issue Dec 14, 2012 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Dec 14, 2012

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

Searchable as RT116096$

@p6rt
Copy link
Author

p6rt commented Dec 14, 2012

From @masak

<sahadev> r​: say ([1, 2], [3, 4]).perl
<p6eval> rakudo fc9c3b​: OUTPUT«([1, 2], [3, 4])␤»
<sahadev> r​: say set([1, 2], [1, 2]).perl
<p6eval> rakudo fc9c3b​: OUTPUT«set("1", "2")␤»
<sahadev> r​: say set(([1, 2], [3, 4])).perl
<p6eval> rakudo fc9c3b​: OUTPUT«set("1", "2", "3", "4")␤»
<sahadev> how do I prevent the list of lists from being flattened when
passed to set()?
<jnthn> Preventing it probably means "fix Rakudo"...
<jnthn> sub set(*@​args) {
<jnthn> Should that be **@​args?
<jnthn> r​: say Set.new([1, 2], [1, 2]).perl
<p6eval> rakudo fc9c3b​: OUTPUT«set("1", "2")␤»
<jnthn> Hm, but method new also does *@​args
* jnthn ain't sure off hand
<jnthn> TimToady​: ^^ if you have a moment :)
<TimToady> [] should not be flattening in list context, and () should
be transparent to list context
<TimToady> r​: my $a = [1,2]; my $b = [3,4]; say set($a,$b).perl
<p6eval> rakudo fc9c3b​: OUTPUT«set("1", "2", "3", "4")␤»
<TimToady> if Set.new is unwrapping Set items into elements, that's wrong
<TimToady> otherwise we can't create a set of sets...
<jnthn> TimToady​: Figured that'd be the answer
<jnthn> masak​: feel free to file ;)
* masak submits rakudobug
<jnthn> Oh wait
* masak waits
<jnthn> r​: sub foo(*@​x) { say @​x.perl }; foo([1,2], [3,4])
<p6eval> rakudo fc9c3b​: OUTPUT«Array.new([1, 2], [3, 4])␤»
<jnthn> ah, ok, that is OK
<jnthn> so it's just a set bug
<jnthn> masak​: file ahead, just wanted to be sure it wasn't a more
general problem :)
* masak files ahead

@p6rt
Copy link
Author

p6rt commented Oct 8, 2014

From @usev6

Arrays are no longer flattened by Set.new​:

say set(([1, 2], [3, 4])).perl
set([1, 2],[3, 4])

I added a test to S02-types/set.t with the following commit​: Raku/roast@e8fd9ec55d

@p6rt
Copy link
Author

p6rt commented Oct 8, 2014

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

@p6rt
Copy link
Author

p6rt commented Oct 8, 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