From e87e61b1520d1b6a4042e26f1e089f2f5ac05c77 Mon Sep 17 00:00:00 2001 From: Gleb Koval Date: Fri, 7 Feb 2025 17:16:23 +0000 Subject: [PATCH] feat: explicitly disallow non-assigned direct function calls --- src/main/wacc/parser.scala | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/wacc/parser.scala b/src/main/wacc/parser.scala index 7d76969..d8b52b4 100644 --- a/src/main/wacc/parser.scala +++ b/src/main/wacc/parser.scala @@ -175,7 +175,15 @@ object parser { ``.label("valid initial value for variable") ) // TODO: Can we inline the name of the variable in the message - | Assign(`` <~ "=", ``) + | Assign( + `` <~ ("=" | "(".verifiedExplain( + "function calls must use the 'call' keyword and the result must be assigned to a variable" + )), + `` + ) | + ("call" ~> ``).verifiedExplain( + "function calls' results must be assigned to a variable" + ) private lazy val ``: Parsley[LValue] = `` | `` private lazy val ``: Parsley[RValue] =