Skip to content

Commit

Permalink
libnixf/Sema: place with warning only on its keyword (#476)
Browse files Browse the repository at this point in the history
Fixes: #475
  • Loading branch information
inclyc authored Apr 28, 2024
1 parent 44b703d commit 8b412c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libnixf/src/Sema/VariableLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ void VariableLookupAnalysis::lookupVar(const ExprVar &Var,
if (Def->syntax()) {
D.note(Note::NK_VarBindToThis, Def->syntax()->range());
}
D.note(Note::NK_EscapingWith, WithEnv->syntax()->range());
const auto &KwWith =
static_cast<const nixf::ExprWith *>(WithEnv->syntax())->kwWith();
D.note(Note::NK_EscapingWith, KwWith.range());
}
return;
}
Expand Down
8 changes: 8 additions & 0 deletions libnixf/test/Sema/VariableLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ TEST_F(VLATest, EscapingWith) {
const Diagnostic &D = Diags[0];

ASSERT_EQ(D.notes().size(), 2);

ASSERT_EQ(D.notes()[0].kind(), Note::NK_VarBindToThis);
ASSERT_EQ(D.notes()[0].range().lCur().offset(), 0);
ASSERT_EQ(D.notes()[0].range().rCur().offset(), 1);

ASSERT_EQ(D.notes()[1].kind(), Note::NK_EscapingWith);
ASSERT_EQ(D.notes()[1].range().lCur().offset(), 3);
ASSERT_EQ(D.notes()[1].range().rCur().offset(), 7);
}

TEST_F(VLATest, InheritRec) {
Expand Down

0 comments on commit 8b412c7

Please sign in to comment.