fix(gen): callable[[]](省略返回类型)按默认 int(i32) 注册函数指针签名,修间接调用签名缺失 fail-fast
This commit is contained in:
1 parent
d3997e0746
commit
444e87dd7d
1 file changed
+7
-2
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user