Skip to content

minify-infinity not doing anything #839

@Cyp

Description

@Cyp

Describe the bug

The minify-infinity pass doesn't do anything.

To Reproduce

const infinities = [Infinity, 1/0, true/false, !0/!1, true/(true/(true/false))];
const zeroes = [1/Infinity, 1/(1/0), false/true, !1/!0, true/(true/false)];
const justone = Infinity;
alert(Infinity);

Actual Output

"use strict";var infinities=[Infinity,1/0,!0/!1,!0/!1,!0/0],zeroes=[1/Infinity,0,0,0,0],justone=Infinity;alert(Infinity);

Expected Output

"use strict";var infinities=[1/0,1/0,1/0,1/0,1/0],zeroes=[0,0,0,0,0],justone=1/0;alert(1/0);

Additional context

It returns here, and therefore doesn't do the substitution:

        if (path.isLVal() && !path.parentPath.isExpressionStatement()) {
          return;
        }

The path.parentPath.type is "ArrayExpression", "BinaryExpression", "VariableDeclarator" and "CallExpression", respectively.

I couldn't find any documentation on what .isExpressionStatement() is actually supposed to do, so I don't know whether the bug is in minify-infinity or in babel itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugConfirmed bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions