in reply to Re^3: ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
in thread ternary operator as lvalue failing to induce evaluation of right-hand expression in list context
Compare
(time ? ($count=()) : $a) = Foo(); ## list+scalar (time ? @a : $a) = Foo(); ## list+scalar (time ? (@a=()) : $a) = Foo(); ## list+scalar (time ? $a=() : $a) = Foo(); ## scalar is scalar (time ? @a=() : $a) = Foo(); ## skates through as scalar $a[0]
It appears perl doesn't recognize the array+assignment(accumulator) as a list without an extra parenthesis, so it does what it thinks should happen
Is this a bug? Yes, in that it already protects programmers from this misunderstanding ( perldiag#Assignment to both a list and a scalar), but it missed this particular variant
Also, Deparse isn't bulletproof :) Deparse says \my(%hash) is the same as \my %hash but it isn't
|
|---|