fix(tpc): 方法调用虚分派——变量与模块短名同名时不误入模块函数路径(base.kind 折叠根因)

This commit is contained in:
TermiNexus committed 2026-08-28 10:23:26 +08:00
1 parent db80178d2e
commit 60dbdfe8d2
2 files changed
+6 -3

No files matched your search

+5 -2
View File
@@ -1038,6 +1038,9 @@ def _parse_atom(ps: Parser | t.CPtr) -> AST | t.CPtr:
if _match_op(ps, TokOp.LBrace):
return _parse_brace(ps)
stdio.printf("[DBG-atom-fail] line=%d col=%d type=%d str='%s' op_id=%d\n",
_cur_lineno(ps), _cur_col(ps), _cur_type(ps),
_cur_str(ps) if _cur_str(ps) is not None else "(null)", _cur_op(ps))
ps.error_count += 1
return None
@@ -1576,7 +1579,7 @@ def _parse_type_ann(ps: Parser | t.CPtr) -> AST | t.CPtr:
ptr_level: t.CInt = 0
# 回收垃圾节点(_parse_test 对后缀 * / ** 的消费产物)
if base.kind() == ASTKind.BinOp:
gb: ast.BinOp | t.CPtr = (ast.BinOp | t.CPtr)(base)
gb: BinOp | t.CPtr = (BinOp | t.CPtr)(base)
if gb.op == OpKind.Mult and gb.right is None:
ptr_level += 1
base = gb.left
@@ -1585,7 +1588,7 @@ def _parse_type_ann(ps: Parser | t.CPtr) -> AST | t.CPtr:
ptr_level += 2
base = gb.left
elif gb.right.kind() == ASTKind.UnaryOp:
gu: ast.UnaryOp | t.CPtr = (ast.UnaryOp | t.CPtr)(gb.right)
gu: UnaryOp | t.CPtr = (UnaryOp | t.CPtr)(gb.right)
if gu.op == OpKind.Deref and gu.operand is None:
ptr_level += 3
base = gb.left
+1 -1
View File
@@ -2787,7 +2787,7 @@ class ExprCallHandle(BaseHandle):
ModuleName = Node.func.value.id
imported = getattr(self.Trans, '_ImportedModules', set())
actual_module = self.Trans.SymbolTable.resolve_alias(ModuleName)
if ModuleName in imported or actual_module in imported:
if (ModuleName in imported or actual_module in imported) and ModuleName not in Gen.var_struct_class:
mangled_name = Gen._mangle_func_name(MethodName, actual_module)
if Gen._has_function(mangled_name):
CallArgs = []