mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 09:14:24 +01:00
Merge 'Return null when parameter is unbound' from Levy A.
Fix #1323. Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #1324
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
use std::num::NonZero;
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error, miette::Diagnostic)]
|
||||
@@ -49,8 +47,6 @@ pub enum LimboError {
|
||||
Constraint(String),
|
||||
#[error("Extension error: {0}")]
|
||||
ExtensionError(String),
|
||||
#[error("Unbound parameter at index {0}")]
|
||||
Unbound(NonZero<usize>),
|
||||
#[error("Runtime error: integer overflow")]
|
||||
IntegerOverflow,
|
||||
#[error("Schema is locked for write")]
|
||||
|
||||
@@ -4395,12 +4395,7 @@ pub fn op_variable(
|
||||
let Insn::Variable { index, dest } = insn else {
|
||||
unreachable!("unexpected Insn {:?}", insn)
|
||||
};
|
||||
state.registers[*dest] = Register::OwnedValue(
|
||||
state
|
||||
.get_parameter(*index)
|
||||
.ok_or(LimboError::Unbound(*index))?
|
||||
.clone(),
|
||||
);
|
||||
state.registers[*dest] = Register::OwnedValue(state.get_parameter(*index));
|
||||
state.pc += 1;
|
||||
Ok(InsnFunctionStepResult::Step)
|
||||
}
|
||||
|
||||
@@ -284,8 +284,11 @@ impl ProgramState {
|
||||
self.parameters.insert(index, value);
|
||||
}
|
||||
|
||||
pub fn get_parameter(&self, index: NonZero<usize>) -> Option<&OwnedValue> {
|
||||
self.parameters.get(&index)
|
||||
pub fn get_parameter(&self, index: NonZero<usize>) -> OwnedValue {
|
||||
self.parameters
|
||||
.get(&index)
|
||||
.cloned()
|
||||
.unwrap_or(OwnedValue::Null)
|
||||
}
|
||||
|
||||
pub fn reset(&mut self) {
|
||||
|
||||
Reference in New Issue
Block a user