diff --git a/src/resolver/function_validation_test.cc b/src/resolver/function_validation_test.cc index 11b704ca18..4cbd7ae8ea 100644 --- a/src/resolver/function_validation_test.cc +++ b/src/resolver/function_validation_test.cc @@ -42,7 +42,8 @@ TEST_F(ResolverFunctionValidationTest, FunctionNamesMustBeUnique_fail) { EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), - "12:34 error v-0016: function names must be unique 'func'"); + R"(12:34 error v-0016: duplicate function named 'func' +note: first function declared here)"); } TEST_F(ResolverFunctionValidationTest, diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index 539e97ec60..5a4d48e231 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -836,12 +836,15 @@ bool Resolver::ValidateParameter(const VariableInfo* info) { bool Resolver::ValidateFunction(const ast::Function* func, const FunctionInfo* info) { - if (symbol_to_function_.find(func->symbol()) != symbol_to_function_.end()) { + auto func_it = symbol_to_function_.find(func->symbol()); + if (func_it != symbol_to_function_.end()) { diagnostics_.add_error("v-0016", - "function names must be unique '" + + "duplicate function named '" + builder_->Symbols().NameFor(func->symbol()) + "'", func->source()); + diagnostics_.add_note("first function declared here", + func_it->second->declaration->source()); return false; }