fix: 修复 throw 未支持静默失败问题
This commit is contained in:
@@ -195,6 +195,9 @@ impl Compiler {
|
|||||||
// FD emits LOAD_CONST(BytecodeFunc) + STORE_VAR
|
// FD emits LOAD_CONST(BytecodeFunc) + STORE_VAR
|
||||||
ctx.projected_pc += 2;
|
ctx.projected_pc += 2;
|
||||||
}
|
}
|
||||||
|
Statement::ThrowStatement(_) => {
|
||||||
|
// throw not yet implemented; emit pass will error
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ impl Compiler {
|
|||||||
|
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
Statement::ThrowStatement(_) => Err("throw statement not supported".into()),
|
||||||
_ => Ok(None),
|
_ => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,6 +116,9 @@ fn hash_statement(stmt: &Statement, h: &mut rustc_hash::FxHasher) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Statement::ThrowStatement(_ts) => {
|
||||||
|
14u8.hash(h);
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
std::mem::discriminant(stmt).hash(h);
|
std::mem::discriminant(stmt).hash(h);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,3 +56,11 @@ fn regression_recursion_depth_limit() {
|
|||||||
"vm error: RangeError: Maximum call stack size exceeded"
|
"vm error: RangeError: Maximum call stack size exceeded"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regression_throw_statement_errors() {
|
||||||
|
assert_eq!(
|
||||||
|
eval("throw 'error'"),
|
||||||
|
"compile error: throw statement not supported"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user