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

es5 will generate illegal js code #7809

Closed
jerrykingxyz opened this issue Aug 15, 2023 · 1 comment · Fixed by #7932
Closed

es5 will generate illegal js code #7809

jerrykingxyz opened this issue Aug 15, 2023 · 1 comment · Fixed by #7932
Labels
Milestone

Comments

@jerrykingxyz
Copy link
Contributor

jerrykingxyz commented Aug 15, 2023

Describe the bug

swc generates illegal js code when i use input code

Input code

async function a(fn) {
    (await fn()).a = "123";
}

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es5",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": true
}

Playground link

https://play.swc.rs/?version=1.3.76&code=H4sIAAAAAAAAA0ssrsxLVkgrzUsuyczPU0jUSMvTVKjmUgACjcTyxMwShbQ8DU1NvUQFWwVDa65aANML9EIwAAAA&config=H4sIAAAAAAAAA1WPSw7DIAxE95wCed1tN71DD2FRJwLxEyZSUZS7Fyikzc4z8%2ByRdyElGFbwkHsdq4iYmNKpq8PFZ3xXB0g5ZJV0zHCbqeEWLWiZunV8E8iYVsp9i%2B8DBxsC08SH57TXS%2FkvVMHFRMxXsKHoV0vXOjEqwYXX1sPxSC6xqXbNBW8YfuRsPK%2BD5udcz2kjcXwAmJf30BkBAAA%3D

Expected behavior

correctly transpile await in left hand side of assignment expressions

Actual behavior

function a(fn) {
    return _a.apply(this, arguments);
}
function _a() {
    _a = _async_to_generator(function(fn) {
        return _ts_generator(this, function(_state) {
            (yield fn()).a = 1; // cannot use yield in ordinary functions
            return [
                2
            ];
        });
    });
    return _a.apply(this, arguments);
}

Version

1.3.76

Additional context

No response

@kdy1 kdy1 added this to the Planned milestone Sep 10, 2023
kdy1 pushed a commit that referenced this issue Sep 10, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.85 Sep 11, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 12, 2023

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 12, 2023
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