Bug #17899 Updated: (Probably) Bug in zend parser

From: Date: Sat, 22 Jun 2002 14:20:39 +0000
Subject: Bug #17899 Updated: (Probably) Bug in zend parser
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-11791@lists.php.net to get a copy of this message
ID: 17899 Updated by: carldrinkwater@mac.com Reported By: othalla@wp.pl Status: Feedback Bug Type: Zend Engine 2 problem Operating System: linux RH6.1 PHP Version: 4.2.1 New Comment: This is in fact a bug, and changing the grammar file as suggested by othalla@wp.pl fixes this problem. Here is a diff to do it ... --- zend_language_parser.y Sat Jun 22 15:12:41 2002 +++ zend_language_parser.old Sat Jun 22 15:18:26 2002 @@ -608,7 +608,7 @@ static_scalar: /* compile-time evaluated scalars */ common_scalar { $$ = $1; } | T_STRING { zend_do_fetch_constant(&$$, NULL, &$1, ZEND_CT TSRMLS_CC); } - | '+' static_scalar { $$ = $2; } + | '+' static_scalar { $$ = $1; } | '-' static_scalar { zval minus_one; minus_one.type = IS_LONG; minus_one.value.lval = -1; mul_function(&$2.u.constant, &$2.u.constant, &minus_one TSRMLS_CC); $$ = $2; } | T_ARRAY '(' static_array_pair_list ')' { $$ = $3; $$.u.constant.type = IS_CONSTANT_ARRAY; } | parse_class_name_entry T_STRING { zend_do_fetch_constant(&$$, &$1, &$2, ZEND_CT TSRMLS_CC); } Previous Comments: ------------------------------------------------------------------------ [2002-06-22 10:03:08] carldrinkwater@mac.com Well, you would expect yacc to return the static_scalar rather than the '+' of this rule ... Here is a script that demonstrates the problem ... <? static $a = +1; static $b = -1; echo $a."\n"; echo $b."\n"; ?> This gives the output ... 2969616 -1 Which as you can see, isn't entirely correct! ------------------------------------------------------------------------ [2002-06-21 12:15:07] sander@php.net This is a Zend Engine 2 problem I guess... Can you elaborate on this 'bug'? Why do you think it's wrong? Can you show us a script, etc... ------------------------------------------------------------------------ [2002-06-21 10:41:52] othalla@wp.pl In zend_language_parser.y there is code: [...] static_scalar: /* compile-time evaluated scalars */ [...] | '+' static_scalar { $$ = $1; } [...] but I think that schould be: [...] static_scalar: /* compile-time evaluated scalars */ [...] | '+' static_scalar { $$ = $2; } [...] ----------------------------------------------------- $2 instead of $1 It's still in PHP 4.3.0-alpha tarball. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17899&edit=1

« previous php.bugs (#11791) next »