mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
fix: return null when parameter is unbound
This commit is contained in:
parent
df11562f69
commit
5c0b112125
3 changed files with 3 additions and 12 deletions
|
@ -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,8 @@ 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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue