diff options
author | Shea Levy <shea@shealevy.com> | 2014-12-09 08:21:36 -0500 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-12-10 12:26:53 +0100 |
commit | 50c33528112d26c0701ce23d435faedb89987b96 (patch) | |
tree | 586c5f83dc47faca18a926727018fa3087f9fdc8 /src | |
parent | 2f16946064b03b92ed5e3a7aea8e222813ea89c2 (diff) |
builtins.readFile: realise context associated with the path
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/primops.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index e7b796046..1ddeac6b2 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()); } |