Improve function name collision error message
Change-Id: Ia1e0460dd0d7b17dab2354311b2989c56143a23f Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/54180 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
cd49e0e074
commit
b4943bab50
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue