Skip Menu |
Report information
Id: 132032
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: zefram [at] fysh.org
Cc:
AdminCc:

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



From: Zefram <zefram [...] fysh.org>
Subject: [BUG] List.new loses Nil
Date: Tue, 5 Sep 2017 11:19:32 +0100
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 348b
Show quoted text
> (3, Nil)
(3 Nil) Show quoted text
> List.new(3, Nil)
(3 (Any)) It is possible (as it should be) to put Nil into a List, if it's constructed using the comma operator. But constructing it via the List.new() constructor replaces the Nil with Any. I think this is a bug in List.new(): it should accept any argument, including Nil, and put it into a List. -zefram
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 677b
On Tue, 05 Sep 2017 03:19:45 -0700, zefram@fysh.org wrote: Show quoted text
> > (3, Nil)
> (3 Nil)
> > List.new(3, Nil)
> (3 (Any)) > > It is possible (as it should be) to put Nil into a List, if it's > constructed using the comma operator. But constructing it via the > List.new() constructor replaces the Nil with Any. I think this is a bug > in List.new(): it should accept any argument, including Nil, and put it > into a List. > > -zefram
Also spotting similar behaviour with Map.new. Since (unlike a Hash), it's not creating containers for its things, I'd expect it to retain the Nil as Nil. m: dd Map.new: ("z", Nil) rakudo-moar f925c6: OUTPUT: «Map.new((:z(Any)))␤»
Download (untitled) / with headers
text/plain 1.2k
On Fri, 15 Sep 2017 11:47:10 -0700, cpan@zoffix.com wrote: Show quoted text
> On Tue, 05 Sep 2017 03:19:45 -0700, zefram@fysh.org wrote:
> > > (3, Nil)
> > (3 Nil)
> > > List.new(3, Nil)
> > (3 (Any)) > > > > It is possible (as it should be) to put Nil into a List, if it's > > constructed using the comma operator. But constructing it via the > > List.new() constructor replaces the Nil with Any. I think this is a > > bug > > in List.new(): it should accept any argument, including Nil, and put > > it > > into a List. > > > > -zefram
> > > Also spotting similar behaviour with Map.new. Since (unlike a Hash), > it's not creating containers for its things, I'd expect it to retain > the Nil as Nil. > > m: dd Map.new: ("z", Nil) > rakudo-moar f925c6: OUTPUT: «Map.new((:z(Any)))␤»
As with #130970 I think this is just a matter of deciding what slurpy/is_raw behavior each of these should have and updating docs/spec/code accordingly. Just before doing that, we need to check on what the roadmap is for some of these types -- are they supposed to be parameterizable and/or have defaults in the future, or not? If so, can we specify, rather than just leave it up to conjecture, that the default parameterization with no default applied will take Nils?


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