Skip Menu |
Report information
Id: 130962
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)



Date: Thu, 9 Mar 2017 11:56:54 +0000
Subject: [BUG] List.Array loses Nil
From: Zefram <zefram [...] fysh.org>
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 282b
Show quoted text
> (Nil,).perl
(Nil,) Show quoted text
> (Nil,).Array.perl
[Any] The coercion from List to Array transforms the Nil element value into an Any. This is a poor coercion. It is perfectly possible for an Array to contain an element of Nil value, so the coercion ought to preserve that value. -zefram
Date: Thu, 9 Mar 2017 13:12:15 +0100
Subject: Re: [perl #130962] [BUG] List.Array loses Nil
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
To: "Zefram (via RT)" <perl6-bugs-followup [...] perl.org>
Show quoted text
> On 9 Mar 2017, at 12:57, Zefram (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by Zefram > # Please include the string: [perl #130962] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=130962 > > >
>> (Nil,).perl
> (Nil,)
>> (Nil,).Array.perl
> [Any] > > The coercion from List to Array transforms the Nil element value into > an Any. This is a poor coercion. It is perfectly possible for an Array > to contain an element of Nil value, so the coercion ought to preserve > that value.
$ 6 'my @a = Nil; dd @a' Array @a = [Any] $ 6 'my @a = (Nil,); dd @a’ # more direct translation Array @a = [Any] $ 6 'dd my @ = (Nil,)' Array @ = [Any] In all of these cases, Nil becomes Any after coercion. The *only* way to keep Nil in here, is to make it the default: $ 6 'dd my @ is default(Nil) = (Nil,)' Array @ = [Nil] I’m not sure we want to do that for all Array coercions, or for all Array creation for that matter (seeing RT #130963).
Date: Thu, 9 Mar 2017 12:32:24 +0000
Subject: Re: [perl #130962] [BUG] List.Array loses Nil
From: Zefram <zefram [...] fysh.org>
To: Elizabeth Mattijsen via RT <perl6-bugs-followup [...] perl.org>
Download (untitled) / with headers
text/plain 732b
Elizabeth Mattijsen via RT wrote: Show quoted text
>The *only* way to keep Nil in here, is to make it the default:
There's also binding: Show quoted text
> my @a; @a[0] := Nil
Nil Show quoted text
> @a[0]
Nil Show quoted text
>I'm not sure we want to do that for all Array coercions,
It's not required for all Array coercions. Only where there's a Nil element value. Show quoted text
>or for all Array creation for that matter (seeing RT #130963).
That one's even more open. Although it's rather surprising behaviour for the [] Array constructor to mangle Nil (since it doesn't overtly involve assignment), I didn't commit to that being the part with the bug. If you'd prefer for [] to keep the Nil manglement, it's open to Array.perl to emit more complex code that doesn't just feed the Nil to []. -zefram


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