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

Helpers break on top-level eval #5441

Closed
Nikaple opened this issue Aug 11, 2022 · 3 comments
Closed

Helpers break on top-level eval #5441

Nikaple opened this issue Aug 11, 2022 · 3 comments
Assignees
Labels
Milestone

Comments

@Nikaple
Copy link
Contributor

Nikaple commented Aug 11, 2022

Describe the bug

When a variable is assigned to eval function, _setPrototypeOf will be removed by the mangler. This will cause a runtime error.

Input code

class A {
  constructor(A) {}
}
class B extends A {
  constructor(B) { super(B) }
}
const C = eval;
new B()

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "target": "es5",
    "minify": {
      "compress": false,
      "mangle": true
    },
    "loose": false
  },
  "minify": true
}

Playground link

https://play.swc.rs/?version=1.2.224&code=H4sIAAAAAAAAA0vOSSwuVnBUqOZSUEjOzysuKSpNLskv0nDUVKiu5arlSgbLOymkVpSk5qVgU%2BkEVKlQXFqQCmaC9YBkFZwVbBVSyxJzrLnyUssVnDQ0AbMGxVtrAAAA&config=H4sIAAAAAAAAA0WLywqEMBAE%2F6XPXr3kb4YwkUheTM%2FCivjvmmXBW9NVdWJnRDgxxKg2F4%2Fm8kWAxiqMlofjWuBim%2Fq8uWJBzS2nY%2Fqx12FKIiQp1AdJ24oiuH30CUvv1D%2B83vBHb9xqQbR%2FAAAA

Expected behavior

No runtime error.

Actual behavior

Uncaught ReferenceError: _setPrototypeOf is not defined

Version

1.2.224

Additional context

No response

@Nikaple Nikaple added the C-bug label Aug 11, 2022
@kdy1
Copy link
Member

kdy1 commented Aug 11, 2022

I think we should apply helper injector before the minifier...

@kdy1 kdy1 added this to the Planned milestone Aug 11, 2022
@kdy1 kdy1 added the P-high label Aug 30, 2022
@kdy1 kdy1 self-assigned this Aug 30, 2022
@kdy1 kdy1 removed the P-high label Aug 30, 2022
@kdy1 kdy1 changed the title Uncaught ReferenceError: _setPrototypeOf is not defined Helpers break on top-level eval Aug 30, 2022
@kdy1 kdy1 removed their assignment Sep 8, 2022
@kdy1 kdy1 self-assigned this Dec 22, 2022
@kdy1
Copy link
Member

kdy1 commented Dec 22, 2022

Duplicate of #5068

@kdy1 kdy1 marked this as a duplicate of #5068 Dec 22, 2022
@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 22, 2022
@kdy1 kdy1 modified the milestones: Planned, v1.3.25 Jan 5, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Feb 4, 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 Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants