forked from lix-project/lix
Merge pull request #6042 from pennae/fix-repl-a
fix nix repl not overriding existing bindings in :a
This commit is contained in:
commit
93293fc66b
|
@ -367,15 +367,19 @@ struct StaticEnv
|
|||
|
||||
void sort()
|
||||
{
|
||||
std::sort(vars.begin(), vars.end(),
|
||||
std::stable_sort(vars.begin(), vars.end(),
|
||||
[](const Vars::value_type & a, const Vars::value_type & b) { return a.first < b.first; });
|
||||
}
|
||||
|
||||
void deduplicate()
|
||||
{
|
||||
const auto last = std::unique(vars.begin(), vars.end(),
|
||||
[] (const Vars::value_type & a, const Vars::value_type & b) { return a.first == b.first; });
|
||||
vars.erase(last, vars.end());
|
||||
auto it = vars.begin(), jt = it, end = vars.end();
|
||||
while (jt != end) {
|
||||
*it = *jt++;
|
||||
while (jt != end && it->first == jt->first) *it = *jt++;
|
||||
it++;
|
||||
}
|
||||
vars.erase(it, end);
|
||||
}
|
||||
|
||||
Vars::const_iterator find(const Symbol & name) const
|
||||
|
|
|
@ -40,3 +40,26 @@ testRepl () {
|
|||
testRepl
|
||||
# Same thing (kind-of), but with a remote store.
|
||||
testRepl --store "$TEST_ROOT/store?real=$NIX_STORE_DIR"
|
||||
|
||||
testReplResponse () {
|
||||
local response="$(nix repl <<< "$1")"
|
||||
echo "$response" | grep -qs "$2" \
|
||||
|| fail "repl command set:
|
||||
|
||||
$1
|
||||
|
||||
does not respond with:
|
||||
|
||||
$2
|
||||
|
||||
but with:
|
||||
|
||||
$response"
|
||||
}
|
||||
|
||||
# :a uses the newest version of a symbol
|
||||
testReplResponse '
|
||||
:a { a = "1"; }
|
||||
:a { a = "2"; }
|
||||
"result: ${a}"
|
||||
' "result: 2"
|
||||
|
|
Loading…
Reference in a new issue