Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Invalid catch param identifier replacement #154

@sebmck

Description

@sebmck

babel/babel#301

Following code incorrectly compiles because the property key identifier err is turned into context$1$0.t0:

Input:

function* foo() {
    try {
        yield someValue;
    } catch (err) {
        var obj = {err: err};
    }
}

Output:

var foo = regeneratorRuntime.mark(function foo() {
    var obj;

    return regeneratorRuntime.wrap(function foo$(context$1$0) {
        while (1) switch (context$1$0.prev = context$1$0.next) {
        case 0:
            context$1$0.prev = 0;
            context$1$0.next = 3;
            return someValue;
        case 3:
            context$1$0.next = 8;
            break;
        case 5:
            context$1$0.prev = 5;
            context$1$0.t0 = context$1$0["catch"](0);
            obj = {context$1$0.t0: context$1$0.t0};
        case 8:
        case "end":
            return context$1$0.stop();
        }
    }, foo, this, [[0, 5]]);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions