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

Bug: used Variable removed #380

Closed
gyandeeps opened this issue Jan 18, 2017 · 1 comment
Closed

Bug: used Variable removed #380

gyandeeps opened this issue Jan 18, 2017 · 1 comment
Labels
bug Confirmed bug

Comments

@gyandeeps
Copy link

gyandeeps commented Jan 18, 2017

Source code

function* idMaker() {
    let cnt = 0;
    while (true) { // eslint-disable-line no-constant-condition
        yield `id-${++cnt}`;
    }
}

0.0.10 output

function idMaker() {
    return regeneratorRuntime.wrap(function (c) {
        for (; ; )
            switch (c.prev = c.next) {
            case 0:
                a = 0;
            case 1:
                return c.next = 4,
                "id-" + ++a;
            case 4:
                c.next = 1;
                break;
            case 6:
            case "end":
                return c.stop()
            }
    }, _marked[0], this)
}

0.0.9 output

function idMaker() {
    var a;
    return regeneratorRuntime.wrap(function (c) {
        for (; ; )
            switch (c.prev = c.next) {
            case 0:
                a = 0;
            case 1:
                return c.next = 4,
                "id-" + ++a;
            case 4:
                c.next = 1;
                break;
            case 6:
            case "end":
                return c.stop()
            }
    }, _marked[0], this)
}

Issue

On line 2, var a; is removed with 0.0.10

Babel: latest

I want to help with this bug if anyone can point me in the right direction. (I have never done babel stuff before)

@boopathi boopathi added the bug Confirmed bug label Jan 18, 2017
@boopathi
Copy link
Member

This is an issue with mangler. Try with presets: [ [ "babili", { deadcode: false } ], "es2015"] and the variable cnt is not mangled, but its references are mangled. Might be the binding/scope issue with babel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants