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:
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user