From a242ad10e6fc7254f894a4c3a2f56d739788da52 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 14 Jun 2020 13:46:46 +0200 Subject: [PATCH] fix double printing of sub param vardecl --- compiler/src/prog8/ast/AstToSourceCode.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/src/prog8/ast/AstToSourceCode.kt b/compiler/src/prog8/ast/AstToSourceCode.kt index 68bc807da..2ecfb8150 100644 --- a/compiler/src/prog8/ast/AstToSourceCode.kt +++ b/compiler/src/prog8/ast/AstToSourceCode.kt @@ -102,6 +102,12 @@ class AstToSourceCode(val output: (text: String) -> Unit, val program: Program): } override fun visit(decl: VarDecl) { + + // if the vardecl is a parameter of a subroutine, don't output it again + val paramNames = (decl.definingScope() as? Subroutine)?.parameters?.map { it.name } + if(paramNames!=null && decl.name in paramNames) + return + when(decl.type) { VarDeclType.VAR -> {} VarDeclType.CONST -> output("const ")