From 960ecdfd741c9480d9dd58b3482231c723df0460 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Fri, 9 Oct 2026 21:34:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(nll):=20=E8=A1=A5=20BoolOp/Compare=20?= =?UTF-8?q?=E7=9A=84=E5=AD=97=E6=AE=B5=E9=80=92=E5=BD=92=EF=BC=88if=201=3D?= =?UTF-8?q?=3D0=20or=20a=20=3D=3D=201=20=E6=9B=BE=E6=8A=8A=E6=95=B4?= =?UTF-8?q?=E6=9D=A1=E5=88=A4=E6=8D=AE=E5=90=A6=E6=8E=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _init_ast 里 node.children = None 是**默认值**(只有语句体这类显式赋值的才有子树),所以"认不出的表达式 一律保守"这条策略会被任何未列举的表达式种类触发。新用例的 if 条件 BoolOp(values) 与 Compare(left/comparators) 就是这种。补上后 h 应能降级,报错位置回到真正的泄漏点 return l(第 19 行)。 --- App/lib/core/Gen/StructGenMixin.vp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/App/lib/core/Gen/StructGenMixin.vp b/App/lib/core/Gen/StructGenMixin.vp index c140722..b50eac6 100644 --- a/App/lib/core/Gen/StructGenMixin.vp +++ b/App/lib/core/Gen/StructGenMixin.vp @@ -766,6 +766,12 @@ novirtual class StructGenMixin: bo: ast.BinOp* = ast.BinOp*(node) if self._NllMentions(bo.left, al) != 0: return 1 return self._NllMentions(bo.right, al) + if k == ast.ASTKind.BoolOp: + return self._NllListMentions(ast.BoolOp*(node).values, al) + if k == ast.ASTKind.Compare: + cp: ast.Compare* = ast.Compare*(node) + if self._NllMentions(cp.left, al) != 0: return 1 + return self._NllListMentions(cp.comparators, al) if k == ast.ASTKind.IfExp: ie: ast.IfExp* = ast.IfExp*(node) if self._NllMentions(ie.test, al) != 0: return 1 @@ -847,6 +853,12 @@ novirtual class StructGenMixin: bo: ast.BinOp* = ast.BinOp*(node) if self._NllExprUnsafe(bo.left, al) != 0: return 1 return self._NllExprUnsafe(bo.right, al) + if k == ast.ASTKind.BoolOp: + return self._NllListUnsafe(ast.BoolOp*(node).values, al) + if k == ast.ASTKind.Compare: + cp: ast.Compare* = ast.Compare*(node) + if self._NllExprUnsafe(cp.left, al) != 0: return 1 + return self._NllListUnsafe(cp.comparators, al) if k == ast.ASTKind.IfExp: ie: ast.IfExp* = ast.IfExp*(node) if self._NllExprUnsafe(ie.test, al) != 0: return 1