refactor(gen): R12 收尾同步——12 处计数 while 循环改 for range
与 includes 同步:<= 条件转 range(expr + 1),并放宽初始化行的紧贴要求(同块内最近一次写即为初始化即可)。其余保守守卫不变。 验证:bootstrap 三重重编 SUCCESS;全量 77/77 顺序回归通过。
This commit is contained in:
1 parent
fb53f88893
commit
aeb4e8e54c
7 files changed
+12
-36
No files matched your search
@@ -433,16 +433,14 @@ def fail_if_fstring_escape(node: ast.AST*, where: str) -> int:
|
||||
elif k == ast.ASTKind.Tuple:
|
||||
tp: ast.Tuple* = ast.Tuple*(node)
|
||||
if tp.elts is not None:
|
||||
i: sizet = 0
|
||||
en: sizet = len(tp.elts)
|
||||
while i < en:
|
||||
for i in range(en):
|
||||
e: ast.AST* = tp.elts.get(i)
|
||||
if e is not None:
|
||||
ek: int = e.kind()
|
||||
if ek == ast.ASTKind.JoinedStr or ek == ast.ASTKind.FormattedValue:
|
||||
hit = 1
|
||||
break
|
||||
i += 1
|
||||
if hit == 0: return 0
|
||||
if _g_gen is not None:
|
||||
_g_gen.TypeGenErr.fatal_error(node, f"f-string 结果不能用于{where}(逃逸):f-string 指向**当前函数的栈缓冲**," f"函数返回即失效,把这个指针带出函数会读到已弹栈的帧" f"(历史事故:ASan stack-buffer-underflow in vsnprintf)。" f"需要带出函数时显式分配后拷贝:" f"tmp: str = f\"...\";out: str = GenApi.escape_fstring_copy(tmp);return out。", "TypeError")
|
||||
|
||||
Reference in new issue
Block a user