> On 9 Mar 2017, at 12:57, Zefram (via RT) <[email protected]> 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).

Reply via email to