bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: typeof() creates elements in an array


From: david kerns
Subject: Re: typeof() creates elements in an array
Date: Mon, 27 Sep 2021 20:44:05 -1000

Not a bug

Remove the typeof operator and you’ll see the array is still increased. 
Referencing the new element increases the length

> On Sep 27, 2021, at 11:13 AM, Ivo Palli <ivo@palli.nl> wrote:
> 
> Hiya,
> 
> After sparring about this on the help mailinglist, I decided to upgrade
> this to a bug.
> 
> This:
> 
> split("123", arr, "");
> print typeof(arr[0]);
> 
> creates a new element on arr[0]. (length(arr)==4)
> 
> This is unexpected since the manual
> 
> https://www.gnu.org/software/gawk/manual/html_node/Type-Functions.html
> 
> says:
> 
>> Normally, passing a variable that has never been used to a built-in
>> function causes it to become a scalar variable (unassigned). However,
>> isarray() and typeof() are different; they do not change their arguments
>> from untyped to unassigned.
> 
> As a regular user I would not expect new elements to be created, and
> honestly I don't see this behavior as useful. I suggest changing it so
> new elements are not created anymore. If this can not be done due to
> language constructs for example, I suggest adding a caveat in the manual.
> 
> Regards,
> 
>   Ivo Palli
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]