repl: Print message when adding variable
I've always been annoyed that it just silently succeeded without any feedback, but now with the upcoming improvements on defining variables this is more necessary than ever. Change-Id: I565897fa2f97cf6f567d4449dcc8d4ad4eb73fce
This commit is contained in:
@@ -10,3 +10,4 @@ The REPL has seen various minor improvements:
|
||||
|
||||
- Better error messages overall
|
||||
- The `:env` command to print currently available variables now also works outside of debug mode
|
||||
- Adding variables to the REPL now prints a small message on success
|
||||
|
||||
+5
-1
@@ -1088,8 +1088,12 @@ 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())
|
||||
if (auto oldVar = staticEnv->find(name); oldVar != staticEnv->vars.end()) {
|
||||
staticEnv->vars.erase(oldVar);
|
||||
notice("Updated %s.", evaluator.symbols[name]);
|
||||
} else {
|
||||
notice("Added %s.", evaluator.symbols[name]);
|
||||
}
|
||||
staticEnv->vars.emplace_back(name, displ);
|
||||
staticEnv->sort();
|
||||
env->values[displ++] = &v;
|
||||
|
||||
Reference in New Issue
Block a user