#44934 [NEW]: The parser doesn't parse a comma
| From: | php at hristov dot com | Date: | Wed, 07 May 2008 11:52:37 +0000 |
| Subject: | #44934 [NEW]: The parser doesn't parse a comma | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-124792@lists.php.net to get a copy of this message | ||
From: php at hristov dot com
Operating system: All
PHP version: 5.3CVS-2008-05-07 (CVS)
PHP Bug Type: Scripting Engine problem
Bug description: The parser doesn't parse a comma
Description:
------------
In the following case the parser bails out:
php -r 'echo true? $t++,"true":"false";'
with
Parse error: syntax error, unexpected ',' in Command line code on line 1
The following mini-C program however does compile, although gcc is kind of
stupid to realize that there should be no warning:
#include <stdio.h>
int main(void)
{
int t=0, f=0;
printf("%s\n", (1==1) ? t++,"True":"False");
}
andrey@whirlpool:~/dev> gcc -o a a.c
andrey@whirlpool:~/dev> ./a
True
The comma does work however when used in a for() loop :
andrey@whirlpool:~/dev> php -r 'for($i=0; $a++, $i < 2; $i++) echo "-";
echo "\n";'
--
Reproduce code:
---------------
php -r 'echo true? $t++,"true":"false";'
Expected result:
----------------
true
--
Edit bug report at http://bugs.php.net/?id=44934&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=44934&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=44934&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=44934&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44934&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=44934&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44934&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44934&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44934&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44934&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44934&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=44934&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=44934&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44934&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44934&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44934&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44934&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44934&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44934&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44934&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44934&r=mysqlcfg