From e9c42c06ef9a1f7af7c34162cc91a0dbeb746202 Mon Sep 17 00:00:00 2001 From: Nick Van den Broeck Date: Thu, 25 Apr 2019 10:49:56 +0200 Subject: [PATCH] Fixed lookupFlake bug --- src/libexpr/primops/flake.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/libexpr/primops/flake.cc b/src/libexpr/primops/flake.cc index d898da1e9..f6744a1f7 100644 --- a/src/libexpr/primops/flake.cc +++ b/src/libexpr/primops/flake.cc @@ -146,15 +146,14 @@ std::shared_ptr getFlagRegistry() return std::make_shared(); } -// This always returns a vector with globalReg, userReg, localReg, flakeReg. +// This always returns a vector with flakeRef, userReg, globalReg. // If one of them doesn't exist, the registry is left empty but does exist. const Registries EvalState::getFlakeRegistries() { Registries registries; - registries.push_back(getGlobalRegistry()); // TODO (Nick): Doesn't this break immutability? - registries.push_back(getUserRegistry()); - registries.push_back(std::make_shared()); // local registries.push_back(getFlagRegistry()); + registries.push_back(getUserRegistry()); + registries.push_back(getGlobalRegistry()); return registries; } @@ -169,8 +168,10 @@ static FlakeRef lookupFlake(EvalState & state, const FlakeRef & flakeRef, const if (i != registry->entries.end()) { auto newRef = i->second; if (std::get_if(&flakeRef.data)) { - if (flakeRef.ref) newRef.ref = flakeRef.ref; - if (flakeRef.rev) newRef.rev = flakeRef.rev; + if (flakeRef.ref || flakeRef.rev) { + newRef.ref = flakeRef.ref; + newRef.rev = flakeRef.rev; + } } std::string errorMsg = "found cycle in flake registries: "; for (FlakeRef oldRef : pastSearches) {