fix(nll): Attribute 节点显式只递归 .value,避免"拿不到子树=算提及"把 stdio.printf(...) 误判成不安全
现场:EscapeTest 的 h = new heap S() 永不降级(g(l,h) 照旧报逃逸)。根因是 _NllMentions 对 Attribute
落进保守分支(children 不含 value 时返回"提及")→ _NllExprUnsafe 把 stdio.printf("%s", h.q) 判为不安全
→ 整个 NLL 判据返回 0。属性名是静态字符串,变量只可能在基对象里,显式递归 .value 即可。
This commit is contained in:
1 parent
d0ffb094c2
commit
337be883d3
1 file changed
+7
@@ -730,6 +730,13 @@ novirtual class StructGenMixin:
|
||||
if nm.id is not None and self._NllInSet(al, nm.id) != 0: return 1
|
||||
return 0
|
||||
if k == ast.ASTKind.Constant: return 0
|
||||
# 属性访问:变量只可能出现在基对象里(`.attr` 是静态字符串),必须显式只递归 .value。
|
||||
# 否则若该节点的 children 不含 value,就会落进下面的"拿不到子树 = 算提及"分支 →
|
||||
# 把 `stdio.printf(...)` 之类误判成提及/不安全,整条 NLL 判据被否掉(现场:该误判
|
||||
# 使 `h = new heap S()` 永不降级,g(l, h) 照旧报逃逸)。
|
||||
if k == ast.ASTKind.Attribute:
|
||||
at: ast.Attribute* = ast.Attribute*(node)
|
||||
return self._NllMentions(at.value, al)
|
||||
ch: list[ast.AST*]* = node.children
|
||||
if ch is None: return 1
|
||||
n: sizet = len(ch)
|
||||
|
||||
Reference in new issue
Block a user