Correct declare_variable example

This commit is contained in:
Shadowfacts 2021-05-16 14:59:08 -04:00
parent 2abf6344d3
commit b3502f257f
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 5 additions and 1 deletions

View File

@ -72,7 +72,11 @@ impl Context {
} }
fn declare_variable(&mut self, name: &str, value: Value) { fn declare_variable(&mut self, name: &str, value: Value) {
self.variables.insert(name.into(), value); if self.variables.contains_key(name) {
panic!("cannot re-declare variable {}", name);
} else {
self.variables.insert(name.into(), value);
}
} }
} }
``` ```