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

View file

@ -756,8 +756,12 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
{ {
PathSet context; PathSet context;
Path path = state.coerceToPath(pos, *args[0], context); Path path = state.coerceToPath(pos, *args[0], context);
if (!context.empty()) try {
throw EvalError(format("string %1% cannot refer to other paths, at %2%") % path % pos); 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()); mkString(v, readFile(path).c_str());
} }