bobthecow/psysh

Fails in some array cases

withinboredom opened this issue · 1 comments

Psysh fails when an array is used in strange (but valid ways):

shorthand appending:

$a = [1,2,3];
$b = [4,5,6];
foreach($b as $a[]);
// FATAL ERROR  Cannot use [] for reading in phar:///usr/local/bin/psysh/src/CodeCleaner/EmptyArrayDimFetchPass.php on line 24.
assert($a, [1,2,3,4,5,6]);

appending a ref to the last inserted item:

$a = [];
$b = &$a[];
//  FATAL ERROR  Cannot use [] for reading in phar:///usr/local/bin/psysh/src/CodeCleaner/EmptyArrayDimFetchPass.php on line 24.
$b = 1;
assert($a, [1]);

Thanks for reporting! These two cases (and a bunch more that are syntactically similar) should be fixed, and will be properly supported in the next stable release.