Bridge canonicalize: add PhiInst.lower_phi and LLVMConstInstructionBox.lower_const diff tests; ArrayBox.pop empty strict tag [array/empty/pop] + smoke; VM README: document [map/missing] and [array/empty/pop] tags

This commit is contained in:
nyash-codex
2025-11-02 11:47:58 +09:00
parent 4011fb2898
commit c81dc20d5c
6 changed files with 133 additions and 1 deletions

View File

@ -39,7 +39,21 @@ impl ArrayBox {
pub fn pop(&self) -> Box<dyn NyashBox> {
match self.items.write().unwrap().pop() {
Some(item) => item,
None => Box::new(crate::boxes::null_box::NullBox::new()),
None => {
let strict = std::env::var("HAKO_OOB_STRICT")
.ok()
.map(|v| matches!(v.as_str(), "1"|"true"|"on"))
.unwrap_or(false)
|| std::env::var("NYASH_OOB_STRICT")
.ok()
.map(|v| matches!(v.as_str(), "1"|"true"|"on"))
.unwrap_or(false);
if strict {
Box::new(StringBox::new("[array/empty/pop] empty array"))
} else {
Box::new(crate::boxes::null_box::NullBox::new())
}
}
}
}