From 7f32042c21afe74c8334ed1cca5c7ef7b765446a Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Fri, 9 Oct 2026 18:44:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(parser):=20new=20=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=94=B9=E6=8C=89=E6=B3=A8=E8=A7=A3=E8=A7=84=E5=88=99?= =?UTF-8?q?=E8=A7=A3=E6=9E=90=EF=BC=8C=E8=AE=A4=20[N]T=20=E5=89=8D?= =?UTF-8?q?=E5=AF=BC=E6=95=B0=E7=BB=84=E5=A3=B0=E6=98=8E=E7=AC=A6=E4=B8=8E?= =?UTF-8?q?=20T*=20=E5=90=8E=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ast/parser.vp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ast/parser.vp b/ast/parser.vp index 29c866c..8b36a03 100644 --- a/ast/parser.vp +++ b/ast/parser.vp @@ -1853,10 +1853,10 @@ def _parse_new_expr(ps: Parser*) -> AST*: src = NEW_SRC_MEMGR continue break - # 类型 + 可选实参:`T(args)` 复用普通表达式解析;`T`(无实参)是基本类型/别名的简写形式 - # (`new stack char`:标量没有构造序列,Gen 侧只需取存储 + 零初始化)。非类型原子(如 - # `new stack f * 2`)仍在此 fail-fast,不能让错误落到"class ... is not registered"那种远离根因的报文。 - callee: AST* = _parse_atom_expr(ps) + # 类型 + 可选实参:类型用**注解规则**解析 —— 这样前导数组声明符 `[N]T`、指针后缀 `T*`、 + # 泛型下标 `list[int]`、描述符前缀都与注解位置同口径;`T(args)` 的实参括号会被 `_parse_test` + # 自身吃成 Call,故这里按"是不是 Call"分流,行为与旧版一致。 + callee: AST* = _parse_type_ann(ps) if callee is None: _record_parse_err(ps) ps.error_count += 1