diff --git a/src/script/C4AulCompiler.cpp b/src/script/C4AulCompiler.cpp index 9626cdfb4..3df09171b 100644 --- a/src/script/C4AulCompiler.cpp +++ b/src/script/C4AulCompiler.cpp @@ -1551,7 +1551,9 @@ void C4AulCompiler::CodegenAstVisitor::visit(const ::aul::ast::VarDecl *n) void C4AulCompiler::CodegenAstVisitor::visit(const ::aul::ast::FunctionDecl *n) { C4PropListStatic *Parent = n->is_global ? target_host->Engine->GetPropList() : target_host->GetPropList(); - C4AulFunc *f = Parent->GetFunc(n->name.c_str()); + + C4String *name = ::Strings.FindString(n->name.c_str()); + C4AulFunc *f = Parent->GetFunc(name); while (f) { if (f->SFunc() && f->SFunc()->pOrgScript == host && f->Parent == Parent) @@ -1563,6 +1565,11 @@ void C4AulCompiler::CodegenAstVisitor::visit(const ::aul::ast::FunctionDecl *n) f = f->SFunc() ? f->SFunc()->OwnerOverloaded : 0; } + if (!Fn && Parent->HasProperty(name)) + { + throw Error(target_host, host, n, Fn, "declaration of '%s': cannot override local variable via 'func %s'", n->name.c_str(), n->name.c_str()); + } + assert(Fn && "CodegenAstVisitor: unable to find function definition"); if (!Fn) throw Error(target_host, host, n, Fn, "internal error: unable to find function definition for %s", n->name.c_str());