Skip to content

Commit

Permalink
error message instead of null for unknown variable
Browse files Browse the repository at this point in the history
  • Loading branch information
fmccl committed Aug 22, 2024
1 parent 417b560 commit 0b1690a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ pub fn run_expr(
current = constants
.get(name)
.or(variables.get(name))
.unwrap_or(&Value::Null)
.ok_or_else(|| {
MolangError::VariableNotFound(name.to_string())
})?
.clone();
} else if let Value::Struct(struc) = current {
current = struc.get(name).unwrap_or(&Value::Null).clone();
Expand Down

0 comments on commit 0b1690a

Please sign in to comment.