diff --git a/crates/oxide_compiler/src/counter.rs b/crates/oxide_compiler/src/counter.rs index 220b7af..b5a0abd 100644 --- a/crates/oxide_compiler/src/counter.rs +++ b/crates/oxide_compiler/src/counter.rs @@ -195,6 +195,9 @@ impl Compiler { // FD emits LOAD_CONST(BytecodeFunc) + STORE_VAR ctx.projected_pc += 2; } + Statement::ThrowStatement(_) => { + // throw not yet implemented; emit pass will error + } _ => {} } } diff --git a/crates/oxide_compiler/src/emitter.rs b/crates/oxide_compiler/src/emitter.rs index 2a7b4e9..75688bd 100644 --- a/crates/oxide_compiler/src/emitter.rs +++ b/crates/oxide_compiler/src/emitter.rs @@ -371,6 +371,7 @@ impl Compiler { Ok(None) } + Statement::ThrowStatement(_) => Err("throw statement not supported".into()), _ => Ok(None), } } diff --git a/crates/oxide_compiler/src/hash.rs b/crates/oxide_compiler/src/hash.rs index 71d1d6c..421d00b 100644 --- a/crates/oxide_compiler/src/hash.rs +++ b/crates/oxide_compiler/src/hash.rs @@ -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); } diff --git a/crates/oxide_vm/tests/regression_tests.rs b/crates/oxide_vm/tests/regression_tests.rs index 6414396..82f031a 100644 --- a/crates/oxide_vm/tests/regression_tests.rs +++ b/crates/oxide_vm/tests/regression_tests.rs @@ -56,3 +56,11 @@ fn regression_recursion_depth_limit() { "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" + ); +}