From 8b05abb80dc2a84dbabae8fa4283b4eeadedff4f Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Wed, 25 Jan 2023 23:41:08 +0100 Subject: [PATCH] proper error when attempting to refer to parameters of asmsub by name --- compiler/src/prog8/compiler/astprocessing/AstChecker.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt index a084d939a..a0f971603 100644 --- a/compiler/src/prog8/compiler/astprocessing/AstChecker.kt +++ b/compiler/src/prog8/compiler/astprocessing/AstChecker.kt @@ -61,6 +61,14 @@ internal class AstChecker(private val program: Program, } } + override fun visit(identifier: IdentifierReference) { + val targetParam = identifier.targetVarDecl(program)?.subroutineParameter + if(targetParam!=null) { + if((targetParam.parent as Subroutine).isAsmSubroutine) + errors.err("cannot refer to parameter of asmsub by name", identifier.position) + } + } + override fun visit(returnStmt: Return) { val expectedReturnValues = returnStmt.definingSubroutine?.returntypes ?: emptyList() if(expectedReturnValues.size>1) {