Bug #78993 [Nab]: Ellipsis inconsistency

From: Date: Thu, 19 Dec 2019 14:41:06 +0000
Subject: Bug #78993 [Nab]: Ellipsis inconsistency
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224421@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78993&edit=1 ID: 78993 Updated by: nikic@php.net Reported by: imbolk at gmail dot com Summary: Ellipsis inconsistency Status: Not a bug Type: Bug Package: *General Issues Operating System: All PHP Version: 7.4.1 Block user comment: N Private report: N New Comment: Of course you can use anything to the right of "...". The point is that "...expr" in itself is not an expression. What is "$a = ...$b" supposed to mean, for example? Only the call(...expr) and [...expr] have any well-defined meaning, and only they are supported. Previous Comments: ------------------------------------------------------------------------ [2019-12-19 14:13:39] imbolk at gmail dot com Oh yes! What about something like this: const ONE=1; var_dump(...array_map(null, [1,2],[3,4])[ONE/ONE-1]); It's works! Isn't that an expression? ------------------------------------------------------------------------ [2019-12-19 08:58:05] d8150650 at urhen dot com BTW var_dump(...[[1],2,3][0]); works fine. ------------------------------------------------------------------------ [2019-12-19 08:54:28] imbolk at gmail dot com What about var_dump(...($a));? ($a) is not expression? ------------------------------------------------------------------------ [2019-12-19 08:01:40] requinix@php.net T_ELLIPSIS can only be used in an array or as a function argument. It unpacks an expression, and it is not an expression itself. ------------------------------------------------------------------------ [2019-12-19 07:35:53] imbolk at gmail dot com Description: ------------ It seems to me that there is an inconsistency in the PHP syntax associated with T_ELLIPSIS. Test script: --------------- $a = [[1,2,3], [4,5,6]]; var_dump(...($a)); var_dump(...(...($a))); Expected result: ---------------- array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(3) { [0]=> int(4) [1]=> int(5) [2]=> int(6) } array(6) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) } Actual result: -------------- array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } array(3) { [0]=> int(4) [1]=> int(5) [2]=> int(6) } PHP Parse error: syntax error, unexpected '...' (T_ELLIPSIS) in Command line code on line… ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78993&edit=1

« previous php.bugs (#224421) next »