Panic on duplicate variable creation

master
Raymon Zutekouw 3 years ago
parent 92d164dd78
commit 1433cf64f5
No known key found for this signature in database
GPG Key ID: 1E9BCC39EDD1DD53
  1. 6
      src/main.rs

@ -81,10 +81,12 @@ fn instruct(statement: Pair<Rule>, state: &mut State, out: &mut Builder) {
Rule::var => {
let variable_name = extract_operand(statement);
println!("Creation of variable '{}'", variable_name);
state.variables.insert(
if let Some(_v) = state.variables.insert(
String::from(variable_name),
MemCell::allocate(state.alloc_cnt),
);
) {
panic!("Variable {} already exists", variable_name);
}
state.alloc_cnt += 1;
}
Rule::delvar => {

Loading…
Cancel
Save