diff --git a/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt b/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt index 339102cec..1cbfe2640 100644 --- a/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt +++ b/compiler/src/prog8/compiler/astprocessing/StatementReorderer.kt @@ -378,6 +378,11 @@ internal class StatementReorderer(val program: Program, } private fun replaceCallSubStatementWithGosub(function: Subroutine, call: FunctionCallStatement, parent: Node): Iterable { + if(function.parameters.isEmpty()) { + // 0 params -> just GoSub + return listOf(IAstModification.ReplaceNode(call, GoSub(null, call.target, null, call.position), parent)) + } + val assignParams = function.parameters.zip(call.args).map { var argumentValue = it.second diff --git a/compilerAst/src/prog8/ast/AstToplevel.kt b/compilerAst/src/prog8/ast/AstToplevel.kt index 4a38f89d8..94b95e7af 100644 --- a/compilerAst/src/prog8/ast/AstToplevel.kt +++ b/compilerAst/src/prog8/ast/AstToplevel.kt @@ -307,12 +307,10 @@ class GlobalNamespace(val modules: Iterable): Node, INameScope { } } -object BuiltinFunctionScopePlaceholder : INameScope { +internal object BuiltinFunctionScopePlaceholder : INameScope { override val name = "<>" override val position = Position("<>", 0, 0, 0) override var statements = mutableListOf() override var parent: Node = ParentSentinel override fun linkParents(parent: Node) {} } - - diff --git a/examples/test.p8 b/examples/test.p8 index 0c3063b36..89c78d6c7 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -16,7 +16,7 @@ main { word @shared ww byte @shared bb - push(-bb) + push(ub+1) pop(ub) txt.print_ub(ub) txt.nl() @@ -25,6 +25,8 @@ main { txt.print_uw(uw) txt.nl() + single(ub+1) + ; uw=10000 ; routines(44,uw+123) ; routines2(44,uw+123) @@ -39,6 +41,10 @@ main { } + sub single(ubyte num) { + num++ + } + sub routine(uword num, ubyte a1, ubyte a2, ubyte switch, byte a3) { txt.print_uw(num) txt.spc()