style: 自动格式化

This commit is contained in:
爱特每羊队
2026-06-30 20:04:27 +08:00
parent b915f127ca
commit 429cb6d9de
4 changed files with 16 additions and 5 deletions
@@ -149,7 +149,10 @@ impl Compiler {
}
// Check if target is a captured cell
if ctx.scopes.symbols.lookup_is_captured(name) {
let cell_idx = ctx.scopes.cell_registry.iter()
let cell_idx = ctx
.scopes
.cell_registry
.iter()
.find(|(n, _)| n == name)
.map(|(_, idx)| *idx)
.unwrap_or(0);
@@ -70,7 +70,10 @@ impl Compiler {
// Check if the owner's binding is captured (cell access)
if ctx.scopes.symbols.lookup_is_captured(name) {
let cell_idx = ctx.scopes.cell_registry.iter()
let cell_idx = ctx
.scopes
.cell_registry
.iter()
.find(|(n, _)| n == name)
.map(|(_, idx)| *idx)
.unwrap_or(0);
+6 -2
View File
@@ -163,7 +163,9 @@ impl Vm {
if cell_ptr.is_null() {
return Ok(());
}
unsafe { (*cell_ptr).value = src_val; }
unsafe {
(*cell_ptr).value = src_val;
}
Ok(())
}
@@ -197,7 +199,9 @@ impl Vm {
if uv_idx < upvals.len() {
let cell = upvals[uv_idx];
if !cell.is_null() {
unsafe { (*cell).value = src_val; }
unsafe {
(*cell).value = src_val;
}
}
}
}
+2 -1
View File
@@ -68,7 +68,8 @@ fn closure_nested_decl_reads_outer_var() {
#[test]
fn closure_counter_escape() {
let result = eval("function counter(){ var n=0; return function(){ return ++n; }; } var c=counter(); c(); c()").unwrap();
let result =
eval("function counter(){ var n=0; return function(){ return ++n; }; } var c=counter(); c(); c()").unwrap();
assert_eq!(result.as_int(), 2);
}