mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
overwrite protection for root env
This commit is contained in:
parent
42441e78c2
commit
7c9ed7ca27
10
src/Env.php
10
src/Env.php
@ -20,4 +20,14 @@ class Env extends Hash
|
||||
|
||||
throw new MadLispException("symbol $key not defined in env");
|
||||
}
|
||||
|
||||
public function set(string $key, $value)
|
||||
{
|
||||
// Do not allow overwriting values in root env
|
||||
if ($this->has($key) && $this->parent == null) {
|
||||
throw new MadLispException("attempt to overwrite $key in root env");
|
||||
}
|
||||
|
||||
return parent::set($key, $value);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user