darklua
darklua copied to clipboard
`remove_assertions` changes return value when used in a call expression
For example, applying remove_assertions
with the default parameter for the rule, the following input:
local head = assert(character:FindFirstChild("Head"), "head is missing!")
becomes:
local head = character:FindFirstChild("Head") and nil
This changes runtime behavior in an unexpected way, because head
is always nil
even when the character does have a child named Head. Expected output is:
local head = character:FindFirstChild("Head")
When preserve_aguments_side_effects
is set to false
, the output is:
local head = nil
Not sure if this is intended either. I think whether the return value is used (so, whether the assert is an expression or a statement?) should probably be factored in here.
Tested on version 0.13.0.