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

Inconsistent conversion output of class #9494

Closed
magic-akari opened this issue Aug 24, 2024 · 2 comments · Fixed by #9519
Closed

Inconsistent conversion output of class #9494

magic-akari opened this issue Aug 24, 2024 · 2 comments · Fixed by #9519
Labels
Milestone

Comments

@magic-akari
Copy link
Member

magic-akari commented Aug 24, 2024

Describe the bug

The transpiled result does not affect correctness, but there is an additional call.

Input code

class Foo1 extends Bar {
    constructor() {
        super(); // ok
    }
}

class Foo2 extends Bar {
    constructor() {
        0, super() // ?
    }
}

class Foo3 extends Bar {
    constructor() {
        [super()] // ?
    }
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "externalHelpers": true,
    "target": "es5",
  }
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.14&code=H4sIAAAAAAAAA0vOSSwuVnDLzzdUSK0oSc1LKVZwSixSqOZSAILk%2FLzikqLS5JL8Ig1NqBgIFJcWpAJFrBX09RXys8HCtVy1XFzJMMOMSDDMQAdmHsg4eyymGZNgWjTUrFhUwwBlIToV5wAAAA%3D%3D&config=H4sIAAAAAAAAAz2LSwqAMAxE956iZO3WjSfwGqEMomgpSYRK6d2NH9zNvDdTuxBo1UhjqB69ZBaF%2FN2Jnsm4OCHEnTXKko0e2fr3g2KQxNuELUPUpyYHPmksM%2By560A3bF27AKSnu8t4AAAA

SWC Info output

No response

Expected behavior

Foo2 and Foo3 should be the same as Foo1, without the need for a _possible_constructor_return call.

Actual behavior

var Foo1 = /*#__PURE__*/ function(Bar1) {
    "use strict";
    _inherits(Foo1, Bar1);
    var _super = _create_super(Foo1);
    function Foo1() {
        _class_call_check(this, Foo1);
        return _super.call(this);
    }
    return Foo1;
}(Bar);
var Foo2 = /*#__PURE__*/ function(Bar1) {
    "use strict";
    _inherits(Foo2, Bar1);
    var _super = _create_super(Foo2);
    function Foo2() {
        _class_call_check(this, Foo2);
        var _this;
        0, _this = _super.call(this) // ?
        ;
        return _possible_constructor_return(_this);
    }
    return Foo2;
}(Bar);
var Foo3 = /*#__PURE__*/ function(Bar1) {
    "use strict";
    _inherits(Foo3, Bar1);
    var _super = _create_super(Foo3);
    function Foo3() {
        _class_call_check(this, Foo3);
        var _this;
        [
            _this = _super.call(this)
        ] // ?
        ;
        return _possible_constructor_return(_this);
    }
    return Foo3;
}(Bar);

Version

1.7.14

Additional context

No response

@kdy1 kdy1 assigned kdy1 and unassigned kdy1 Aug 24, 2024
@kdy1 kdy1 added this to the Planned milestone Aug 24, 2024
@magic-akari
Copy link
Member Author

I will attempt to reimplement the super transformation, aligning with Babel's behavior as demonstrated in babel/babel#16194.

@swc-bot
Copy link
Collaborator

swc-bot commented Oct 3, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants