Skip to content

Commit

Permalink
Merge pull request #183 from stargazing-dino/update_variables
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim authored Mar 4, 2024
2 parents 5e4917f + c24f2ff commit 79857b6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/runtime/src/virtual_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,16 +501,19 @@ impl VirtualMachine {
// value may be found in the program. (If it's
// not, then the variable's value is undefined,
// which isn't allowed.)

Ok(self
let initial_value = self
.program
.as_ref()
.unwrap()
.initial_values
.get(&variable_name)
.unwrap_or_else(|| panic!("The loaded program does not contain an initial value for the variable {variable_name}"))
.clone()
.into())
.clone();

// Store the initial value in the variable_storage
self.variable_storage.set(variable_name.clone(), initial_value.clone().into())?;

Ok(initial_value.into())
} else {
Err(e)
}
Expand Down

0 comments on commit 79857b6

Please sign in to comment.