-
Notifications
You must be signed in to change notification settings - Fork 175
Closed
Labels
bugSomething isn't workingSomething isn't workingwaiting for releaseThe issue has been fixed, but the fix is not included in the current release.The issue has been fixed, but the fix is not included in the current release.
Description
Describe the bug
The DivExpression in ast.lua has a simplify argument which will perform the division and store the result if both left and right-hand side of the expression is a constant. This works great in all cases except when dividing by 0.
print(1/0) -- inf
print(-1/0) -- -inf
print(0/0) -- nan
The above three expressions return constants inf and nan of type number. The problem when simplifying this is that the resulting string will become:
print(inf) -- nil
print(-inf) -- attempt to perform arithmetic on global 'inf' (a nil value)
print(nan) -- nil
Expected behavior
The DivExpression should not simplify the expression when the right hand side is 0.
To Reproduce
Steps to reproduce the behavior:
- Create a file
divexpression.luacontainingprint(-1/0) - Run
lua cli.lua --preset Weak divexpression.lua
Observe divexpression.obfuscated.lua
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingwaiting for releaseThe issue has been fixed, but the fix is not included in the current release.The issue has been fixed, but the fix is not included in the current release.