@@ -3179,6 +3179,28 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
31793179
31803180 /* We will throw if $this doesn't exist, so there's no need to emit a JMP_NULL
31813181 * check for a nullsafe access. */
3182+ } else if (obj_ast -> kind == ZEND_AST_CONST
3183+ && (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET
3184+ || type == BP_VAR_FUNC_ARG )) {
3185+ zend_ast * name_ast = obj_ast -> child [0 ];
3186+ bool is_fully_qualified ;
3187+ zend_string * orig_name = zend_ast_get_str (name_ast );
3188+ zend_string * resolved_name = zend_resolve_const_name (
3189+ orig_name , name_ast -> attr , & is_fully_qualified );
3190+
3191+ opline = zend_emit_op (& obj_node , ZEND_FETCH_CONSTANT , NULL , NULL );
3192+ opline -> op2_type = IS_CONST ;
3193+
3194+ if (is_fully_qualified || !FC (current_namespace )) {
3195+ opline -> op1 .num = 0 ;
3196+ opline -> op2 .constant = zend_add_const_name_literal (
3197+ resolved_name , false);
3198+ } else {
3199+ opline -> op1 .num = IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE ;
3200+ opline -> op2 .constant = zend_add_const_name_literal (
3201+ resolved_name , true);
3202+ }
3203+ opline -> extended_value = zend_alloc_cache_slot ();
31823204 } else {
31833205 zend_short_circuiting_mark_inner (obj_ast );
31843206 opline = zend_delayed_compile_var (& obj_node , obj_ast , type , false);
@@ -11309,7 +11331,7 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */
1130911331}
1131011332/* }}} */
1131111333
11312- static void zend_compile_const (znode * result , const zend_ast * ast , uint32_t type ) /* {{{ */
11334+ static void zend_compile_const (znode * result , const zend_ast * ast ) /* {{{ */
1131311335{
1131411336 zend_ast * name_ast = ast -> child [0 ];
1131511337
@@ -11343,11 +11365,7 @@ static void zend_compile_const(znode *result, const zend_ast *ast, uint32_t type
1134311365 return ;
1134411366 }
1134511367
11346- if (type == BP_VAR_R || type == BP_VAR_IS ) {
11347- opline = zend_emit_op_tmp (result , ZEND_FETCH_CONSTANT , NULL , NULL );
11348- } else {
11349- opline = zend_emit_op (result , ZEND_FETCH_CONSTANT , NULL , NULL );
11350- }
11368+ opline = zend_emit_op_tmp (result , ZEND_FETCH_CONSTANT , NULL , NULL );
1135111369 opline -> op2_type = IS_CONST ;
1135211370
1135311371 if (is_fully_qualified || !FC (current_namespace )) {
@@ -12222,7 +12240,7 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
1222212240 zend_compile_array (result , ast );
1222312241 return ;
1222412242 case ZEND_AST_CONST :
12225- zend_compile_const (result , ast , BP_VAR_R );
12243+ zend_compile_const (result , ast );
1222612244 return ;
1222712245 case ZEND_AST_CLASS_CONST :
1222812246 zend_compile_class_const (result , ast );
@@ -12318,9 +12336,6 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
1231812336 case ZEND_AST_ASSIGN :
1231912337 zend_compile_assign (result , ast , false, type );
1232012338 return NULL ;
12321- case ZEND_AST_CONST :
12322- zend_compile_const (result , ast , type );
12323- return NULL ;
1232412339 default :
1232512340 if (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET ) {
1232612341 zend_error_noreturn (E_COMPILE_ERROR ,
0 commit comments