Correct declare_variable example
This commit is contained in:
parent
2abf6344d3
commit
b3502f257f
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue