From 50c33528112d26c0701ce23d435faedb89987b96 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Tue, 9 Dec 2014 08:21:36 -0500 Subject: builtins.readFile: realise context associated with the path --- src/libexpr/primops.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index e7b79604699b..1ddeac6b2f88 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -756,8 +756,12 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va { PathSet context; Path path = state.coerceToPath(pos, *args[0], context); - if (!context.empty()) - throw EvalError(format("string ‘%1%’ cannot refer to other paths, at %2%") % path % pos); + try { + realiseContext(context); + } catch (InvalidPathError & e) { + throw EvalError(format("cannot read ‘%1%’, since path ‘%2%’ is not valid, at %3%") + % path % e.path % pos); + } mkString(v, readFile(path).c_str()); } -- cgit 1.4.1