From 444e87dd7d89c7496ea8bf16a6a1544389c0dbae Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Tue, 13 Oct 2026 13:26:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(gen):=20callable[[]]=EF=BC=88=E7=9C=81?= =?UTF-8?q?=E7=95=A5=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B=EF=BC=89=E6=8C=89?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=20int(i32)=20=E6=B3=A8=E5=86=8C=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E6=8C=87=E9=92=88=E7=AD=BE=E5=90=8D=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E9=97=B4=E6=8E=A5=E8=B0=83=E7=94=A8=E7=AD=BE=E5=90=8D=E7=BC=BA?= =?UTF-8?q?=E5=A4=B1=20fail-fast?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/lib/core/Gen/Type/TypeGenErr.vp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/App/lib/core/Gen/Type/TypeGenErr.vp b/App/lib/core/Gen/Type/TypeGenErr.vp index dee3e29..a357627 100644 --- a/App/lib/core/Gen/Type/TypeGenErr.vp +++ b/App/lib/core/Gen/Type/TypeGenErr.vp @@ -102,10 +102,15 @@ novirtual class TypeGenErr(TypeGenBase.TypeGenBase): # The subscript test uses TypeGenResolve as the single source of truth (the t.Callable # Attribute form is equivalent to the bare-name callable / Callable forms) if self.Gen.TypeGenResolve._IsCallableSubscriptValue(sub_cr.value) == 0: return None - # slice must be Tuple(elts=[args_list, ret_node]) + # slice must be Tuple(elts=[args_list, ret_node]); the one-element form + # `callable[[A, B]]` omits the return type and means the default int (i32) — the same + # degradation a missing annotation gets elsewhere. It must still register, otherwise the + # indirect call fails fast with "Return type ... is not registered". if sub_cr.slice is None or sub_cr.slice.kind() != ast.ASTKind.Tuple: return None tp_cr: ast.Tuple* = ast.Tuple*(sub_cr.slice) - if tp_cr.elts is None or len(tp_cr.elts) != 2: return None + if tp_cr.elts is None: return None + if len(tp_cr.elts) == 1: return mlirlite.Int32(pool) + if len(tp_cr.elts) != 2: return None ret_node_cr: ast.AST* = tp_cr.elts.get(1) if ret_node_cr is None: return None return self.Gen.TypeGenResolve.resolve_annotation_type(pool, ret_node_cr, imported_modules, from_imports, trans, 0)