diff --git a/libnixf/src/Sema/VariableLookup.cpp b/libnixf/src/Sema/VariableLookup.cpp index 6766a969f..b4db77202 100644 --- a/libnixf/src/Sema/VariableLookup.cpp +++ b/libnixf/src/Sema/VariableLookup.cpp @@ -53,8 +53,10 @@ void VariableLookupAnalysis::lookupVar(const ExprVar &Var, EnvNode *CurEnv = Env.get(); std::shared_ptr Def; for (; CurEnv; CurEnv = CurEnv->parent()) { - if (CurEnv->defs().contains(Name)) + if (CurEnv->defs().contains(Name)) { Def = CurEnv->defs().at(Name); + break; + } // Find the most nested `with` expression, and set uses. if (CurEnv->isWith() && !EnclosedWith) { EnclosedWith = true; diff --git a/libnixf/test/Sema/VariableLookup.cpp b/libnixf/test/Sema/VariableLookup.cpp index f900bd6f3..b6f18d038 100644 --- a/libnixf/test/Sema/VariableLookup.cpp +++ b/libnixf/test/Sema/VariableLookup.cpp @@ -133,8 +133,7 @@ TEST_F(VLATest, LivenessNested) { ASSERT_EQ(Diags.size(), 1); ASSERT_EQ(Diags[0].kind(), Diagnostic::DK_DefinitionNotUsed); - // FIXME: this should be place at 'let y = 1;' - ASSERT_EQ(Diags[0].range().lCur().column(), 17); + ASSERT_EQ(Diags[0].range().lCur().column(), 8); ASSERT_EQ(Diags[0].tags().size(), 1); ASSERT_EQ(Diags[0].tags()[0], DiagnosticTag::Faded); }