fix(stubgen): 装饰器循环变量改名 ddi,避免与默认值处的注解声明 di 冲突
同一个函数里 di 先被 for 循环绑定为 int(i32),后面又用注解声明为 sizet(i64) 且右值是运行期 i64 值:存储类型 i32 收不下,编译器按 fail-fast 报'带注解重声明冲突'(此前 TPC 是静默丢掉 store,生成的 viperc.exe 在 list[AST*].get 越界读)。装饰器循环改用 ddi,di 保持为首次声明。
This commit is contained in:
1 parent
7da9d7cb0d
commit
a143c2de0c
1 file changed
+6
-2
@@ -442,8 +442,12 @@ def _PyiFunction(buf: bytes, buf_size: sizet, pos: sizet, fn: ast.FunctionDef*,
|
||||
if fn.decorator_list is not None:
|
||||
fn_decorator_list: list[ast.AST*]* = fn.decorator_list
|
||||
dn: sizet = len(fn_decorator_list)
|
||||
for di in range(int(dn)):
|
||||
dec: ast.AST* = fn_decorator_list.get(di)
|
||||
# 循环变量改名:`di` 在下方默认值处理处被注解声明为 sizet(i64)。若这里先用
|
||||
# `di`(range → int/i32)绑定,注解重声明就会与既有 i32 存储冲突 —— 编译器按
|
||||
# fail-fast 报“带注解重声明冲突”,此前 TPC 是静默丢掉 store(生成的二进制在
|
||||
# list[AST*].get 处越界读)。故装饰器循环变量改用 ddi。
|
||||
for ddi in range(int(dn)):
|
||||
dec: ast.AST* = fn_decorator_list.get(ddi)
|
||||
if dec is not None:
|
||||
pos = _PyiIndent(buf, buf_size, pos, indent_level)
|
||||
pos = _PyiEmit(buf, buf_size, pos, "@")
|
||||
|
||||
Reference in new issue
Block a user