Subject: | zero, the empty string, and "0" are erroneously interpreted as NIL |
Those which are false in a boolean test (zero, the empty string and "0")
are erroneously interpreted as NIL.
* Steps to reproduce:
$list = LISP->new([2, 0, 1]); # (2 0 1)
printf "%s\n", $list->string; # (2 NIL 1)!!!
* The cause of the bug
The subroutine "new" of LISP::List is buggy. Lines 52-54:
my $car = ref eq 'ARRAY' && $class->new($_)
|| defined && $_
|| $NIL;
The fourth conditional expression is evaluated as false because $_ is 0,
and $NIL is assigned to $car.