diff --git a/libnixf/src/Sema/VariableLookup.cpp b/libnixf/src/Sema/VariableLookup.cpp index d5056398d..6d0dac263 100644 --- a/libnixf/src/Sema/VariableLookup.cpp +++ b/libnixf/src/Sema/VariableLookup.cpp @@ -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(WithEnv->syntax())->kwWith(); + D.note(Note::NK_EscapingWith, KwWith.range()); } return; } diff --git a/libnixf/test/Sema/VariableLookup.cpp b/libnixf/test/Sema/VariableLookup.cpp index 7b98ef591..b154847b8 100644 --- a/libnixf/test/Sema/VariableLookup.cpp +++ b/libnixf/test/Sema/VariableLookup.cpp @@ -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) {