* 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.
This commit is contained in:
Eelco Dolstra 2006-09-24 21:39:57 +00:00
parent 0e705391db
commit e347033f71
2 changed files with 13 additions and 4 deletions

View file

@ -267,6 +267,7 @@ string coerceToStringWithContext(EvalState & state,
if (a && evalString(state, a) == "derivation") { if (a && evalString(state, a) == "derivation") {
a = attrs.get(toATerm("outPath")); a = attrs.get(toATerm("outPath"));
if (!a) throw TypeError("output path missing from derivation"); if (!a) throw TypeError("output path missing from derivation");
isPath = true;
context = ATinsert(context, e); context = ATinsert(context, e);
return evalPath(state, a); return evalPath(state, a);
} }

View file

@ -114,7 +114,9 @@ void toString(EvalState & state, Expr e,
int n; int n;
Expr e2; Expr e2;
bool isWrapped = false;
while (matchContext(e, es, e2)) { while (matchContext(e, es, e2)) {
isWrapped = true;
e = e2; e = e2;
for (ATermIterator i(es); i; ++i) for (ATermIterator i(es); i; ++i)
context = ATinsert(context, *i); context = ATinsert(context, *i);
@ -146,7 +148,7 @@ void toString(EvalState & state, Expr e,
else if (matchPath(e, s)) { else if (matchPath(e, s)) {
Path path(canonPath(aterm2String(s))); Path path(canonPath(aterm2String(s)));
if (!isStorePath(path)) { if (!isInStore(path)) {
if (isDerivation(path)) if (isDerivation(path))
throw EvalError(format("file names are not allowed to end in `%1%'") 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);
} }
path = dstPath; result += dstPath;
context = ATinsert(context, makePath(toATerm(dstPath)));
} }
else {
result += path; result += path;
context = ATinsert(context, makePath(toATerm(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)) { else if (matchList(e, es)) {