diff --git a/libnixf/src/Sema/VariableLookup.cpp b/libnixf/src/Sema/VariableLookup.cpp index 70040124a..d5056398d 100644 --- a/libnixf/src/Sema/VariableLookup.cpp +++ b/libnixf/src/Sema/VariableLookup.cpp @@ -177,12 +177,10 @@ std::shared_ptr VariableLookupAnalysis::dfsAttrs( auto NewEnv = std::make_shared(Env, DB.finish(), Syntax); - // inherit (expr) attrs; - // ~~~~~~<------- this expression should have "parent scope". for (const auto &[_, Attr] : SA.staticAttrs()) { if (!Attr.value()) continue; - dfs(*Attr.value(), Attr.fromInherit() ? Env : NewEnv); + dfs(*Attr.value(), NewEnv); } dfsDynamicAttrs(SA.dynamicAttrs(), NewEnv); diff --git a/libnixf/test/Sema/VariableLookup.cpp b/libnixf/test/Sema/VariableLookup.cpp index a3771d765..7b98ef591 100644 --- a/libnixf/test/Sema/VariableLookup.cpp +++ b/libnixf/test/Sema/VariableLookup.cpp @@ -262,4 +262,14 @@ TEST_F(VLATest, EscapingWith) { ASSERT_EQ(D.notes().size(), 2); } +TEST_F(VLATest, InheritRec) { + // Make sure inheirt (expr), the expression is binded to "NewEnv". + std::shared_ptr AST = + parse("rec { inherit (foo) bar; foo.bar = 1; }", Diags); + VariableLookupAnalysis VLA(Diags); + VLA.runOnAST(*AST); + + ASSERT_EQ(Diags.size(), 0); +} + } // namespace