diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 1235135945..1eeec2cf19 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -215,7 +215,11 @@ static void checkVarDefs2(set & done, const ATermMap & defs, Expr e) ATerm with, body; ATermList rbnds, nrbnds; - if (matchVar(e, name)) { + /* Closed terms don't have free variables, so we don't have to + check by definition. */ + if (matchClosed(e, value)) return; + + else if (matchVar(e, name)) { if (!defs.get(name)) throw EvalError(format("undefined variable `%1%'") % aterm2String(name));