Improve error message for clash between variable and function name

The previous error message was very cryptic and led to an abort.

Fixes GH-1832
This commit is contained in:
Johanna Amann 2021-12-09 19:15:33 +00:00
parent 7a6501296b
commit e1dc09e230

View file

@ -618,8 +618,14 @@ void begin_func(IDPtr id, const char* module_name, FunctionFlavor flavor, bool i
std::optional<FuncType::Prototype> prototype; std::optional<FuncType::Prototype> prototype;
if ( id->GetType() ) if ( id->GetType() )
{
if ( id->GetType()->Tag() != TYPE_FUNC )
{
id->Error("Function clash with previous definition with incompatible type", t.get());
reporter->FatalError("invalid definition of '%s' (see previous errors)", id->Name());
}
prototype = get_prototype(id, t); prototype = get_prototype(id, t);
}
else if ( is_redef ) else if ( is_redef )
id->Error("redef of not-previously-declared value"); id->Error("redef of not-previously-declared value");