From e1dc09e230ed994f9ed57664847d2c1491c3ab44 Mon Sep 17 00:00:00 2001 From: Johanna Amann Date: Thu, 9 Dec 2021 19:15:33 +0000 Subject: [PATCH] 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 --- src/Var.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Var.cc b/src/Var.cc index dc8a04251b..5437b11c33 100644 --- a/src/Var.cc +++ b/src/Var.cc @@ -618,8 +618,14 @@ void begin_func(IDPtr id, const char* module_name, FunctionFlavor flavor, bool i std::optional prototype; 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); - + } else if ( is_redef ) id->Error("redef of not-previously-declared value");