instanceof has higher precedence than casts
| From: | Jan Lehnardt | Date: | Mon, 16 Feb 2004 14:59:53 +0000 |
| Subject: | instanceof has higher precedence than casts | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-7876@lists.php.net to get a copy of this message | ||
Hi,
some dude on IRC found out that
php -r 'var_export((object)1 instanceof stdClass);';
results in
class stdClass {
public $scalar = false;
}
IMHO it should just return true. The ZEND_ENGINE file
doesn't state anything about the precedence of instanceof.
The fix is pretty simple and a patch to zend_language_parser.y
is attached.
make test runs through fine, so I guess it doesn't brake
anything else, but I can't tell for sure of course. It
would be great if someone could look into this.
Best regards,
Jan
--
GPG Key: BB96 56B0
Q: Thank Jan? - A: http://geschenke.an.dasmoped.net/
Index: zend_language_parser.y =================================================================== RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.138 diff -u -r1.138 zend_language_parser.y --- zend_language_parser.y 11 Feb 2004 22:13:39 -0000 1.138 +++ zend_language_parser.y 16 Feb 2004 14:51:33 -0000 @@ -67,9 +67,10 @@ %left T_SL T_SR %left '+' '-' '.' %left '*' '/' '%' +%nonassoc T_INSTANCEOF %right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' %right '[' -%nonassoc T_NEW T_INSTANCEOF T_CLONE +%nonassoc T_NEW T_CLONE %token T_EXIT %token T_IF %left T_ELSEIF
Index: zend_language_parser.y =================================================================== RCS file: /repository/ZendEngine2/zend_language_parser.y,v retrieving revision 1.138 diff -u -r1.138 zend_language_parser.y --- zend_language_parser.y 11 Feb 2004 22:13:39 -0000 1.138 +++ zend_language_parser.y 16 Feb 2004 14:51:33 -0000 @@ -67,9 +67,10 @@ %left T_SL T_SR %left '+' '-' '.' %left '*' '/' '%' +%nonassoc T_INSTANCEOF %right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@' %right '[' -%nonassoc T_NEW T_INSTANCEOF T_CLONE +%nonassoc T_NEW T_CLONE %token T_EXIT %token T_IF %left T_ELSEIF