From e347033f718e23d1ae6821207124465fedc73db1 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sun, 24 Sep 2006 21:39:57 +0000 Subject: [PATCH] * The result of a concatenation with a derivation on the left-hand side should be a path, I guess. * Handle paths that are in the store but not direct children of the store directory. * Ugh, hack to prevent double context wrapping. --- src/libexpr/eval.cc | 1 + src/libexpr/primops.cc | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 3334e4bbd..416d43b33 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -267,6 +267,7 @@ string coerceToStringWithContext(EvalState & state, if (a && evalString(state, a) == "derivation") { a = attrs.get(toATerm("outPath")); if (!a) throw TypeError("output path missing from derivation"); + isPath = true; context = ATinsert(context, e); return evalPath(state, a); } diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 96ce4f71e..9a856ca40 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -114,7 +114,9 @@ void toString(EvalState & state, Expr e, int n; Expr e2; + bool isWrapped = false; while (matchContext(e, es, e2)) { + isWrapped = true; e = e2; for (ATermIterator i(es); i; ++i) context = ATinsert(context, *i); @@ -146,7 +148,7 @@ void toString(EvalState & state, Expr e, else if (matchPath(e, s)) { Path path(canonPath(aterm2String(s))); - if (!isStorePath(path)) { + if (!isInStore(path)) { if (isDerivation(path)) throw EvalError(format("file names are not allowed to end in `%1%'") @@ -162,11 +164,17 @@ void toString(EvalState & state, Expr e, % path % dstPath); } - path = dstPath; + result += dstPath; + context = ATinsert(context, makePath(toATerm(dstPath))); } - result += path; - context = ATinsert(context, makePath(toATerm(path))); + else { + result += path; + /* !!! smells hacky. Check whether this is the Right + Thing To Do. */ + if (!isWrapped) + context = ATinsert(context, makePath(toATerm(toStorePath(path)))); + } } else if (matchList(e, es)) {