Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Hamm-m opened this issue Sep 18, 2017 · 0 comments
Closed
Labels
bug Confirmed bug has PR Has an open PR that fixes this issue
Milestone

Comments

@Hamm-m
Copy link

Hamm-m commented Sep 18, 2017

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".

@boopathi boopathi added the bug Confirmed bug label Sep 19, 2017
@boopathi boopathi added this to the 1.0 milestone Nov 18, 2017
@boopathi boopathi added the has PR Has an open PR that fixes this issue label Dec 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug has PR Has an open PR that fixes this issue
Projects
None yet
Development

No branches or pull requests

2 participants