fix(TPC): 继承链 vtable 状态追溯 + 默认参数检查信息缺失保护

- _resolve_class_flags 沿 class_parent 链追溯 vtable 状态:Stmt/ExprNode 空中间基类(@t.CVTable 无方法)跨模块未注册 class_vtable,子类 IsCVTable 误判为 False → __before_init__ base=0 不写 vtable → 实例 vtable=null → 虚调用段错误。改为沿链查找任一祖先有 vtable 即继承。

- 函数调用严格参数检查:默认参数信息缺失(跨模块 stub 加载/并行编译时序未同步)时跳过检查,避免 fatal_error 误报缺少必需参数。
This commit is contained in:
TermiNexus committed 2026-08-10 23:01:43 +08:00
1 parent a941179826
commit d687216772
2 files changed
+32 -8

No files matched your search

+15 -6
View File
@@ -1445,12 +1445,21 @@ class ExprCallHandle(BaseHandle):
func_defaults = gv
break
total_params: int = len(exact_param_names)
num_defaults: int = len(func_defaults) if func_defaults else 0
min_args: int = total_params - num_defaults
# 只检查必需参数(有默认值的参数允许缺失)
for i in range(min_args):
if i >= provided and i not in kw_provided:
raise Exception(f"调用 {ModulePath}.{func_name}() 缺少必需参数 '{exact_param_names[i]}',该参数没有默认值")
if func_defaults is None:
# 默认参数信息缺失(跨模块 stub 加载:vpi/stub 只含参数
# 类型不含默认值;或并行编译时序导致定义模块的默认参数
# 尚未注册到共享表)→ 无法准确计算必需参数数量,
# 跳过严格检查避免误报(如 HandlesType.fatal_error 的
# err_type/col_start/col_end 默认值未同步时误报"缺 arg3")。
# 同文件函数的参数检查由 FunctionDef 路径(L1983)覆盖。
pass
else:
num_defaults: int = len(func_defaults)
min_args: int = total_params - num_defaults
# 只检查必需参数(有默认值的参数允许缺失)
for i in range(min_args):
if i >= provided and i not in kw_provided:
raise Exception(f"调用 {ModulePath}.{func_name}() 缺少必需参数 '{exact_param_names[i]}',该参数没有默认值")
elif ModulePath in Gen.ModuleSha1Map and len(Node.args) == 0:
func = Gen.functions.get(mangled_name)
if func and len(func.function_type.args) > 0: