From: Dmitry Stogov Date: Mon, 3 Oct 2005 08:21:20 +0000 (+0000) Subject: Fixed bug #34358 (Fatal error: Cannot re-assign $this) X-Git-Tag: RELEASE_0_9_0~46 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eedbae57ae2814119df1475bc780ad76dc1cabb5;p=php Fixed bug #34358 (Fatal error: Cannot re-assign $this) --- diff --git a/Zend/tests/bug34358.phpt b/Zend/tests/bug34358.phpt new file mode 100755 index 0000000000..b9c6565f51 --- /dev/null +++ b/Zend/tests/bug34358.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #34358 (Fatal error: Cannot re-assign $this(again)) +--FILE-- +bar(); +echo "ok\n"; +?> +--EXPECT-- +ok diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2a19b0398f..866ebe205d 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -596,7 +596,8 @@ void zend_do_assign(znode *result, znode *variable, znode *value TSRMLS_DC) *result = last_op->result; return; } else { - if (opline_is_fetch_this(last_op TSRMLS_CC)) { + if (variable->op_type == IS_VAR && + opline_is_fetch_this(last_op TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); } } @@ -626,7 +627,8 @@ void zend_do_assign_ref(znode *result, znode *lvar, znode *rvar TSRMLS_DC) if (last_op_number > 0) { zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; - if (opline_is_fetch_this(last_op TSRMLS_CC)) { + if (lvar->op_type == IS_VAR && + opline_is_fetch_this(last_op TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); } }