Skip to content

remove_assertions changes return value when used in a call expression #189

@sircfenner

Description

@sircfenner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions