From e9038a5978dce4fdd0a67d3a0cbb3b35c2cb8cd3 Mon Sep 17 00:00:00 2001 From: cesare Date: Fri, 5 Feb 2021 12:20:15 +0000 Subject: [PATCH] Enforce top level function names cannot clash with function argument names --- source/modules/soul_core/compiler/soul_SanityCheckPass.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/modules/soul_core/compiler/soul_SanityCheckPass.h b/source/modules/soul_core/compiler/soul_SanityCheckPass.h index eca23be..fa10ad2 100644 --- a/source/modules/soul_core/compiler/soul_SanityCheckPass.h +++ b/source/modules/soul_core/compiler/soul_SanityCheckPass.h @@ -589,6 +589,14 @@ struct SanityCheckPass final for (auto& param : f.parameters) duplicateNameChecker.check (param->name, param->context); + + if (f.block != nullptr) + { + // Ensure top level block variables do not duplicate parameter names + for (auto& s : f.block->statements) + if (auto v = cast (s)) + duplicateNameChecker.check (v->name, v->context); + } } void visit (AST::StructDeclaration& s) override