Skip to content

Commit

Permalink
libnixf/Sema: fix misplaced nested liveness diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Apr 8, 2024
1 parent e1fb0b8 commit 7c28007
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion libnixf/src/Sema/VariableLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ void VariableLookupAnalysis::lookupVar(const ExprVar &Var,
EnvNode *CurEnv = Env.get();
std::shared_ptr<Definition> 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;
Expand Down
3 changes: 1 addition & 2 deletions libnixf/test/Sema/VariableLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 7c28007

Please sign in to comment.