Skip to content

Commit c5cedbd

Browse files
committed
Fix (?) AST and name resolution
1 parent deedb02 commit c5cedbd

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

Zend/zend_ast.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,16 @@ static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int
15691569
zend_ast_export_ex(str, ast, priority, indent);
15701570
}
15711571

1572+
static ZEND_COLD void zend_ast_export_class_name(smart_str *str, zend_ast *ast, int priority, int indent)
1573+
{
1574+
if (ast->kind == ZEND_AST_CLASS_REF) {
1575+
ZEND_ASSERT(ast->child[1] == NULL && "Generic params not supported yet");
1576+
zend_ast_export_ns_name(str, ast->child[0], priority, indent);
1577+
return;
1578+
}
1579+
zend_ast_export_ex(str, ast, priority, indent);
1580+
}
1581+
15721582
static ZEND_COLD bool zend_ast_valid_var_char(char ch)
15731583
{
15741584
unsigned char c = (unsigned char)ch;
@@ -1689,7 +1699,7 @@ static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list
16891699
if (i != 0) {
16901700
smart_str_appends(str, separator);
16911701
}
1692-
zend_ast_export_name(str, list->child[i], 0, indent);
1702+
zend_ast_export_ns_name(str, list->child[i], 0, indent);
16931703
i++;
16941704
}
16951705
}
@@ -2443,6 +2453,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
24432453
smart_str_appends(str, "::");
24442454
zend_ast_export_name(str, ast->child[1], 0, indent);
24452455
break;
2456+
case ZEND_AST_CLASS_REF:
2457+
ZEND_ASSERT(false && "TODO");
2458+
break;
24462459
case ZEND_AST_CLASS_NAME:
24472460
if (ast->child[0] == NULL) {
24482461
/* The const expr representation stores the fetch type instead. */
@@ -2456,7 +2469,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
24562469
EMPTY_SWITCH_DEFAULT_CASE()
24572470
}
24582471
} else {
2459-
zend_ast_export_ns_name(str, ast->child[0], 0, indent);
2472+
zend_ast_export_class_name(str, ast->child[0], 0, indent);
24602473
}
24612474
smart_str_appends(str, "::class");
24622475
break;
@@ -2724,17 +2737,6 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
27242737
smart_str_appends(str, ": ");
27252738
ast = ast->child[1];
27262739
goto tail_call;
2727-
// TODO Export generic types
2728-
//case ZEND_AST_ASSOCIATED_TYPE:
2729-
// smart_str_appends(str, "type ");
2730-
// zend_ast_export_name(str, ast->child[0], 0, indent);
2731-
// if (ast->child[1]) {
2732-
// smart_str_appends(str, " : ");
2733-
// smart_str_appends(str, " : ");
2734-
// zend_ast_export_type(str, ast->child[1], indent);
2735-
// }
2736-
// smart_str_appendc(str, ';');
2737-
//break;
27382740

27392741
/* 3 child nodes */
27402742
case ZEND_AST_METHOD_CALL:

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9120,7 +9120,7 @@ static zend_string *zend_generate_anon_class_name(zend_ast_decl *decl)
91209120
prefix = zend_resolve_const_class_name_reference(decl->child[0], "class name");
91219121
} else if (decl->child[1]) {
91229122
zend_ast_list *list = zend_ast_get_list(decl->child[1]);
9123-
prefix = zend_resolve_const_class_name_reference(list->child[0], "interface name");
9123+
prefix = zend_resolve_const_class_name_reference_with_generics(list->child[0], "interface name");
91249124
}
91259125

91269126
zend_string *result = zend_strpprintf(0, "%s@anonymous%c%s:%" PRIu32 "$%" PRIx32,

0 commit comments

Comments
 (0)