P0-1: Map bad-key tags for get/set/delete + smokes; String substring clamp smoke; P0-2: Bridge no‑op(Method) + Gate‑C invalid header smokes; P1: v1 bridge Closure captures appended to argv

This commit is contained in:
nyash-codex
2025-11-02 13:29:27 +09:00
parent ff62eb0d97
commit 110b4f3321
14 changed files with 275 additions and 59 deletions

View File

@ -64,7 +64,12 @@ pub(super) fn try_handle_map_box(
}
"set" => {
if args.len() != 2 { return Err(VMError::InvalidInstruction("MapBox.set expects 2 args".into())); }
let k = this.reg_load(args[0])?.to_nyash_box();
let k_vm = this.reg_load(args[0])?;
if !matches!(k_vm, VMValue::String(_)) {
if let Some(d) = dst { this.regs.insert(d, VMValue::String("[map/bad-key] key must be string".to_string())); }
return Ok(true);
}
let k = k_vm.to_nyash_box();
let v = this.reg_load(args[1])?.to_nyash_box();
let ret = mb.set(k, v);
if let Some(d) = dst { this.regs.insert(d, VMValue::from_nyash_box(ret)); }
@ -72,7 +77,12 @@ pub(super) fn try_handle_map_box(
}
"get" => {
if args.len() != 1 { return Err(VMError::InvalidInstruction("MapBox.get expects 1 arg".into())); }
let k = this.reg_load(args[0])?.to_nyash_box();
let k_vm = this.reg_load(args[0])?;
if !matches!(k_vm, VMValue::String(_)) {
if let Some(d) = dst { this.regs.insert(d, VMValue::String("[map/bad-key] key must be string".to_string())); }
return Ok(true);
}
let k = k_vm.to_nyash_box();
let ret = mb.get(k);
if let Some(d) = dst { this.regs.insert(d, VMValue::from_nyash_box(ret)); }
return Ok(true);
@ -86,7 +96,12 @@ pub(super) fn try_handle_map_box(
}
"delete" => {
if args.len() != 1 { return Err(VMError::InvalidInstruction("MapBox.delete expects 1 arg".into())); }
let k = this.reg_load(args[0])?.to_nyash_box();
let k_vm = this.reg_load(args[0])?;
if !matches!(k_vm, VMValue::String(_)) {
if let Some(d) = dst { this.regs.insert(d, VMValue::String("[map/bad-key] key must be string".to_string())); }
return Ok(true);
}
let k = k_vm.to_nyash_box();
let ret = mb.delete(k);
if let Some(d) = dst { this.regs.insert(d, VMValue::from_nyash_box(ret)); }
return Ok(true);