# -*- coding: utf-8 -*- """临时脚本:修复 MatchGenMixin.vp 三处 dbody = dmc.children(普通赋值触发 TPC 跨模块 RHS 类型推断失败 → 退化 list[int] → get 截断指针)。改完即删。""" import io path = r"d:\Users\TermiNexus\Desktop\TransPyC\TransPyV\App\lib\core\Gen\MatchGenMixin.vp" with io.open(path, "r", encoding="utf-8") as f: content = f.read() old = "dbody = dmc.children" new = ( "dbody2: list[ast.AST | t.CPtr] | t.CPtr = dmc.children\n" " dbody = dbody2" ) count = content.count(old) if count != 3: raise SystemExit(f"预期 3 处,实际 {count} 处,中止") content = content.replace(old, new) with io.open(path, "w", encoding="utf-8", newline="\n") as f: f.write(content) print(f"OK: replaced {count} occurrences")