builtins.readFile: realise context associated with the path

This commit is contained in:
Shea Levy 2014-12-09 08:21:36 -05:00 committed by Eelco Dolstra
parent 2f16946064
commit 50c3352811
1 changed files with 6 additions and 2 deletions

View File

@ -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());
}