japhib / pico8-ls

PICO-8 Language Server
MIT License
64 stars 8 forks source link

Formatter removing necessary parentheses in math #50

Open icegoat9 opened 7 months ago

icegoat9 commented 7 months ago

I saw some unexpected program behavior after autoformatting, and tracked it down to the formatter removing necessary parentheses in math expressions, which changes the order of operations.

Simple example:

x = 20 - (2 + 3 * 4)

autoformats to:

x = 20 - 2 + 3 * 4

Another example:

x = not (true and false)

Autoformats to the logically different expression:

x = not true and false