From ff1294207e90d0718656f45d957e6518c5e803a9 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 2 Jul 2019 00:06:40 +0200 Subject: [PATCH] improved parameter name shadowing check --- compiler/src/prog8/ast/AST.kt | 15 ++++- .../src/prog8/ast/AstIdentifiersChecker.kt | 18 ++++-- compiler/src/prog8/ast/StmtReorderer.kt | 4 +- examples/test.p8 | 64 ++++--------------- 4 files changed, 38 insertions(+), 63 deletions(-) diff --git a/compiler/src/prog8/ast/AST.kt b/compiler/src/prog8/ast/AST.kt index 8dee3526e..dab8bd641 100644 --- a/compiler/src/prog8/ast/AST.kt +++ b/compiler/src/prog8/ast/AST.kt @@ -429,7 +429,7 @@ interface INameScope { } fun getLabelOrVariable(name: String): IStatement? { - // this is called A LOT and could perhaps be optimized a bit more, but adding a cache didn't make much of a practical runtime difference + // TODO this is called A LOT and could perhaps be optimized a bit more, but adding a cache didn't make much of a practical runtime difference for (stmt in statements) { if (stmt is VarDecl && stmt.name==name) return stmt if (stmt is Label && stmt.name==name) return stmt @@ -437,8 +437,17 @@ interface INameScope { return null } - fun allDefinedNames(): Set = - statements.filterIsInstance