From be91604feff1b5b89c54f1c9d3179f16765f8f6f Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Thu, 6 Aug 2026 14:29:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20upvalue=5Fcaptures=20=E6=8C=89=E5=90=8D?= =?UTF-8?q?=E5=AD=97=E6=8E=92=E5=BA=8F=EF=BC=8C=E4=BF=AE=E5=A4=8D=20HashSe?= =?UTF-8?q?t=20=E9=9D=9E=E7=A1=AE=E5=AE=9A=E9=A1=BA=E5=BA=8F=E8=87=B4=20LO?= =?UTF-8?q?AD=5FUPVALUE=20=E9=94=99=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_emit/src/closure.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/oxide_emit/src/closure.rs b/crates/oxide_emit/src/closure.rs index b0c50fd4..9c5071b5 100644 --- a/crates/oxide_emit/src/closure.rs +++ b/crates/oxide_emit/src/closure.rs @@ -508,6 +508,12 @@ impl Emitter { let parent_names: HashSet = parent_captured.keys().cloned().collect(); let mut names = HashSet::new(); self.collect_capture_names_shadowed(body_stmts, &parent_names, sub_own, &mut names); + // HashSet 迭代序带随机种子(进程级非确定),必须排序使 upvalue_captures 的顺序与 + // 父 captured_bindings 的 cell_idx(BTreeMap 名字序)对齐——否则 uv_idx(identifier.rs + // LOAD_UPVALUE 的 a 槽编码)与 cell_idx 错位,读错 upvalue(hoisted_function_reads_outer_var_and_function + // 抖动根因)。 + let mut names: Vec = names.into_iter().collect(); + names.sort(); names .into_iter() .map(|name| {