diff --git a/App/lib/core/Gen/StmtGenMixin.vp b/App/lib/core/Gen/StmtGenMixin.vp index e8085db..4325fb2 100644 --- a/App/lib/core/Gen/StmtGenMixin.vp +++ b/App/lib/core/Gen/StmtGenMixin.vp @@ -261,7 +261,10 @@ class StmtGenMixin: cls_name: str = None ce: ast.AST | t.CPtr = item.context_expr if ce.kind() == ast.ASTKind.Call: - cfn: ast.AST | t.CPtr = ((ast.Call | t.CPtr)(ce)).func + # 注意:联合类型转换后必须经中间变量再取属性(直接 + # ((ast.Call|CPtr)(ce)).func 会被 TPC 编译损坏丢弃属性访问) + call_ce: ast.Call | t.CPtr = (ast.Call | t.CPtr)(ce) + cfn: ast.AST | t.CPtr = call_ce.func if cfn is not None: if cfn.kind() == ast.ASTKind.Attribute: ca: ast.Attribute | t.CPtr = (ast.Attribute | t.CPtr)(cfn) @@ -276,7 +279,8 @@ class StmtGenMixin: if cls_name is None: cls_name = ca.attr elif cfn.kind() == ast.ASTKind.Name: - cls_name = ((ast.Name | t.CPtr)(cfn)).id + nm_cfn: ast.Name | t.CPtr = (ast.Name | t.CPtr)(cfn) + cls_name = nm_cfn.id # context 对象存入 __with_ctx(方法调用解析 self 用) ctx_alloca: llvmlite.Value | t.CPtr = llvmlite.build_alloca( builder, ctx_val.Ty) @@ -295,7 +299,9 @@ class StmtGenMixin: if item.optional_vars is not None: ov: ast.AST | t.CPtr = item.optional_vars if ov.kind() == ast.ASTKind.Name: - asname: str = ((ast.Name | t.CPtr)(ov)).id + # 联合类型转换后经中间变量再取属性(同 L264 注释,防 TPC 编译损坏) + ovn: ast.Name | t.CPtr = (ast.Name | t.CPtr)(ov) + asname: str = ovn.id if asname is not None: bind_val: llvmlite.Value | t.CPtr = enter_val if bind_val is None: