diff options
author | regnat <rg@regnat.ovh> | 2021-12-09 16:35:27 +0100 |
---|---|---|
committer | regnat <rg@regnat.ovh> | 2021-12-09 16:35:27 +0100 |
commit | 55e3a1108cb41801c92d3697620408d9d272c2d2 (patch) | |
tree | 33c7c4281c838c389f60eb735e88bfd036725fb3 /src/nix | |
parent | bc57b3854e75d3f20929fd63d69a98b8237f23b2 (diff) |
Properly take the last assignment in the REPL
When a variable is assigned in the REPL, make sure to remove any possible reference to the old one so that we correctly pick the new one afterwards
Fix #5706
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/repl.cc | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc index 42143871f..f453343f3 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -672,6 +672,8 @@ void NixRepl::addVarToScope(const Symbol & name, Value & v) { if (displ >= envSize) throw Error("environment full; cannot add more variables"); + if (auto oldVar = staticEnv.find(name); oldVar != staticEnv.vars.end()) + staticEnv.vars.erase(oldVar); staticEnv.vars.emplace_back(name, displ); staticEnv.sort(); env->values[displ++] = &v; |