Index: Zend/zend_compile.c =================================================================== RCS file: /repository/ZendEngine2/zend_compile.c,v retrieving revision 1.647.2.24 diff -u -p -d -r1.647.2.24 zend_compile.c --- Zend/zend_compile.c 20 Mar 2006 15:13:41 -0000 1.647.2.24 +++ Zend/zend_compile.c 21 Mar 2006 12:58:14 -0000 @@ -580,7 +580,9 @@ void zend_do_assign(znode *result, znode SET_UNUSED(opline->result); *result = last_op->result; return; - } else if (opline_is_fetch_this(last_op TSRMLS_CC)) { + } else if (CG(active_op_array)->scope && CG(active_op_array)->function_name && + !(CG(active_op_array)->fn_flags & ZEND_ACC_STATIC) && + opline_is_fetch_this(last_op TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); } else { break; @@ -614,8 +616,10 @@ void zend_do_assign_ref(znode *result, z if (last_op_number > 0) { zend_op *last_op = &CG(active_op_array)->opcodes[last_op_number-1]; - if (lvar->op_type == IS_VAR && - opline_is_fetch_this(last_op TSRMLS_CC)) { + if (lvar->op_type == IS_VAR && CG(active_op_array)->scope && + CG(active_op_array)->function_name && + !(CG(active_op_array)->fn_flags & ZEND_ACC_STATIC) && + opline_is_fetch_this(last_op TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot re-assign $this"); } }