Skip to content

lua minify error: result missing parentheses with e.g. (x+a)//y #447

@ElMoonLite

Description

@ElMoonLite

The LUA minify seems to handle operator precedence wrong in some cases.

e.g.
Entering return (x+6)//4 will result in return x+6//4 which is NOT the same.
The latter would be evaluated as return x+(6//4).
If it helps, another way to look at it is that it would change something like floor((x+6)/4) to x + floor(6/4).

I'm guessing because internally + and // are incorrectly handled as same precedence?

See:
https://www.lua.org/pil/3.5.html -- However, note that // is missing here.
https://www.lua.org/manual/5.4/manual.html#3.4.8 -- Here // is shown to have the same precedence as: * / // %

Maybe while fixing this bug, also check other operator precedence issues?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions