fix(func): extern/export 声明跳过掉出末尾检查
FunctionDef.Extern/Export 为真时视为声明型函数,不再要求显式 return。
This commit is contained in:
1 parent
da638a018b
commit
88645fe7da
1 file changed
+3
-1
@@ -2101,7 +2101,9 @@ class FunctionHandle(BaseHandle):
|
||||
_DeclMarkers: tuple[str, ...] = (
|
||||
tuple(getattr(Node, 'Markers', None) or ())
|
||||
+ tuple(getattr(Node.returns, 'Markers', None) or ()))
|
||||
_IsDecl: bool = any(m in ('state', 'export', 'extern') for m in _DeclMarkers)
|
||||
_IsDecl: bool = (any(m in ('state', 'export', 'extern') for m in _DeclMarkers)
|
||||
or bool(getattr(Node, 'Extern', False))
|
||||
or bool(getattr(Node, 'Export', False)))
|
||||
if not _IsDecl and not _IsVoidOrDeclAnnotation(Node.returns):
|
||||
raise Exception(
|
||||
f"函数 {Node.name} 声明了返回类型但函数体可能掉出末尾(缺少 return 语句);"
|
||||
|
||||
Reference in new issue
Block a user