feat: explicitly disallow non-assigned direct function calls

This commit is contained in:
Gleb Koval 2025-02-07 17:16:23 +00:00
parent 4631f4370e
commit e87e61b152
Signed by: cyclane
GPG Key ID: 15E168A8B332382C

View File

@ -175,7 +175,15 @@ object parser {
`<rvalue>`.label("valid initial value for variable") `<rvalue>`.label("valid initial value for variable")
) )
// TODO: Can we inline the name of the variable in the message // TODO: Can we inline the name of the variable in the message
| Assign(`<lvalue>` <~ "=", `<rvalue>`) | Assign(
`<lvalue>` <~ ("=" | "(".verifiedExplain(
"function calls must use the 'call' keyword and the result must be assigned to a variable"
)),
`<rvalue>`
) |
("call" ~> `<ident>`).verifiedExplain(
"function calls' results must be assigned to a variable"
)
private lazy val `<lvalue>`: Parsley[LValue] = private lazy val `<lvalue>`: Parsley[LValue] =
`<pair-elem>` | `<ident-or-array-elem>` `<pair-elem>` | `<ident-or-array-elem>`
private lazy val `<rvalue>`: Parsley[RValue] = private lazy val `<rvalue>`: Parsley[RValue] =