From 02031da61aeeeb24b7e03c06ddb3fd04c05ad67c Mon Sep 17 00:00:00 2001 From: Karol Stasiak Date: Thu, 18 Feb 2021 00:38:51 +0100 Subject: [PATCH] Correctly optimize variables around macros --- .../scala/millfork/compiler/AbstractStatementPreprocessor.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/millfork/compiler/AbstractStatementPreprocessor.scala b/src/main/scala/millfork/compiler/AbstractStatementPreprocessor.scala index c9619e44..a1eb6741 100644 --- a/src/main/scala/millfork/compiler/AbstractStatementPreprocessor.scala +++ b/src/main/scala/millfork/compiler/AbstractStatementPreprocessor.scala @@ -181,7 +181,7 @@ abstract class AbstractStatementPreprocessor(protected val ctx: CompilationConte cv = search(arg, cv) cv = search(ve, cv) Assignment(ve, optimizeExpr(arg, cv)).pos(pos) -> cv - case ExpressionStatement(expr@FunctionCallExpression(fname, List(VariableExpression(v), arg))) + case ExpressionStatement(expr@FunctionCallExpression(fname, _)) if ctx.env.maybeGet[Thing](fname).exists(i => i.isInstanceOf[MacroFunction]) => ExpressionStatement(optimizeExpr(expr, Map())).pos(pos) -> Map() case ExpressionStatement(expr@FunctionCallExpression("+=", List(VariableExpression(v), arg)))