Skip to content

Boolean return statements are changed to (un)defined by minify-simplify #689

@Hamm-m

Description

@Hamm-m

Input Code

function(object, property, value) {
    if (object && property) {
        object[property] = value;
        return true;
    }
    return false;
}

Actual Output

return object && property && (object[property] = value, true);

Expected Output

return !!(object && property && (object[property]=value));

Details

When a function returns true/false conditionally based on check of input parameters, this seems to be flattened into a single condition using logical operator && in between. Because of that the result of the above function behaves differently in case when input arguments (object, property) are not provided by the client call.

Calling the function originally with no parameters returns "false".
Calling the function after being transformed by minify-simplify with no parameters returns "undefined".

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bughas PRHas an open PR that fixes this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions