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

Wrong compress with undefined (which is declared by user) on void 0 #8567

Closed
INeedJobToStartWork opened this issue Jan 28, 2024 · 1 comment · Fixed by #9146
Closed

Wrong compress with undefined (which is declared by user) on void 0 #8567

INeedJobToStartWork opened this issue Jan 28, 2024 · 1 comment · Fixed by #9146
Labels
Milestone

Comments

@INeedJobToStartWork
Copy link

INeedJobToStartWork commented Jan 28, 2024

Describe the bug

Compress Option does wrong transform undefined which is overrided and return void 0 anyway.

I just reported it because i have seen that - Probably not important
Edit: uncomment console.log to check that everything back to normal

Input code

const templatePath = () => {
  const undefined = "lol1"
  return undefined
};
const templatePath2 = (() => {
  const undefined = "lol"
  return undefined
})();



console.log(templatePath())
console.log(templatePath2)
// console.log(undefined) 

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true
    },
    "target": "es5",
    "loose": true,
    "minify": {
      "compress": {
        "arguments": false,
        "arrows": true,
        "booleans": true,
        "booleans_as_integers": false,
        "collapse_vars": true,
        "comparisons": true,
        "computed_props": true,
        "conditionals": true,
        "dead_code": true,
        "directives": true,
        "drop_console": false,
        "drop_debugger": true,
        "evaluate": true,
        "expression": false,
        "hoist_funs": false,
        "hoist_props": true,
        "hoist_vars": false,
        "if_return": true,
        "join_vars": true,
        "keep_classnames": false,
        "keep_fargs": true,
        "keep_fnames": false,
        "keep_infinity": false,
        "loops": true,
        "negate_iife": true,
        "properties": true,
        "reduce_funcs": false,
        "reduce_vars": false,
        "side_effects": true,
        "switches": true,
        "typeofs": true,
        "unsafe": false,
        "unsafe_arrows": false,
        "unsafe_comps": false,
        "unsafe_Function": false,
        "unsafe_math": false,
        "unsafe_symbols": false,
        "unsafe_methods": false,
        "unsafe_proto": false,
        "unsafe_regexp": false,
        "unsafe_undefined": false,
        "unused": true,
        "const_to_let": true,
        "pristine_globals": true
      },
      "mangle": {
        "toplevel": false,
        "keep_classnames": false,
        "keep_fnames": false,
        "keep_private_props": false,
        "ie8": false,
        "safari10": false
      }
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.107&code=H4sIAAAAAAAAA0vOzysuUShJzS3ISSxJDUgsyVCwVdDQVLC1U6jm5VJQSAbLl%2BalpKZl5qWmACWVcvJzDJVAckWpJaVFeQhJXq5aa16uZAwTjUBGEjQTl5GaGppAUyEQpDM%2FJ1UvJz9dA9kGDU1N3JJGQDl9fQVkabj5QCkA%2BJyuxQIBAAA%3D&config=H4sIAAAAAAAAA42VzW7bMAyA732KwOcetsOGoQ%2Bw255BUCzKUSeLhkilCYq8e2nZTr2GNnYxbH78ESmSfn86HJpXapuXw7u8ysdgM0G%2Bf4uErontRSQNXwegNoeBm%2BeFMo2Ic4EquU2gYZs74NEI6Mes3UREgll7FvUhBX9dh2uxHzIQrWQiFXelh8Sj2NtI8LxmGd%2FoH79VfkSMYNMOMZZMSAwdZM1xizHagcCcbVa8jCe1ORBqIUZYGJwZMg4qTy5wwCQxH6kD60yLDhQUMrQczqCZSSwxSyTpKflU7OBYuq5e8RdrONtYLCsx4VKvRE6reD1hIDa%2BJK2EE9yowQTn4n61DN5k4JLTo90rhrRxJ38BpALREiXbg%2Ba3anjppy1rv2sZkpeW5avCpb21LBN0UlQTglcqO1YGMgftNjO40sJY2VY7zow3ykfBgQHvpVcU1%2FQWuD1pQccZR68AuV%2Frta6agLlP4QYfB2IH%2F5YsWW%2BwWaO3fNqmdO2PGHcC9MAndDsKchWM2zjLlrgM27wkB9Ia4FSVQhU8LgEZAEYT66586A0ZD%2FFouojHzzUxK9zuK7i3qavzvtqXjEOEM8StNv6PEdmlcrbz2NXLZD9ML%2FzSmtLK4IXv3xa0pPK0PGtSTY%2BurBKqPTn9Sn42n0rLn%2BMepAn0Z7Gshbp9AG%2BGZ%2FvfBgAA

SWC Info output

I did it Only on website in Playground .

Expected behavior

Should Return console.log("lol1"), console.log("lol2");

Actual behavior

Current return: console.log(void 0), console.log(void 0);

Version

1.3.107

Additional context

Not needed - Just found in random testing.

@kdy1 kdy1 self-assigned this Jan 29, 2024
@kdy1 kdy1 added this to the Planned milestone Jan 29, 2024
@kdy1 kdy1 removed their assignment Jan 29, 2024
@kdy1 kdy1 assigned kdy1 and unassigned kdy1 Mar 12, 2024
@kdy1 kdy1 closed this as completed in #9146 Jul 5, 2024
@kdy1 kdy1 closed this as completed in 1a739b7 Jul 5, 2024
@kdy1 kdy1 modified the milestones: Planned, v1.6.10 Jul 6, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Aug 5, 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 Aug 5, 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