diff --git a/libnixf/src/Sema/VariableLookup.cpp b/libnixf/src/Sema/VariableLookup.cpp index 0f28cf700..294ea5beb 100644 --- a/libnixf/src/Sema/VariableLookup.cpp +++ b/libnixf/src/Sema/VariableLookup.cpp @@ -48,6 +48,9 @@ void VariableLookupAnalysis::emitEnvLivenessWarning( // the lambda signature. if (Def->source() == Definition::DS_LambdaArg) continue; + // Ignore builtins usage. + if (!Def->syntax()) + continue; if (Def->uses().empty()) { Diagnostic &D = Diags.emplace_back(Diagnostic::DK_DefinitionNotUsed, Def->syntax()->range()); diff --git a/libnixf/test/Sema/VariableLookup.cpp b/libnixf/test/Sema/VariableLookup.cpp index e0c420bff..41d0de70b 100644 --- a/libnixf/test/Sema/VariableLookup.cpp +++ b/libnixf/test/Sema/VariableLookup.cpp @@ -316,4 +316,17 @@ rec { ASSERT_EQ(Diags[0].range().lCur().line(), 3); } +TEST_F(VLATest, Issue533) { + const char *Src = R"( +let ; +in 1 + )"; + + std::shared_ptr AST = parse(Src, Diags); + VariableLookupAnalysis VLA(Diags); + VLA.runOnAST(*AST); + + ASSERT_EQ(Diags.size(), 1); +} + } // namespace