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

The string compression output for escape(\) is not as expected #8407

Closed
jigsawye opened this issue Dec 8, 2023 · 1 comment · Fixed by #8520
Closed

The string compression output for escape(\) is not as expected #8407

jigsawye opened this issue Dec 8, 2023 · 1 comment · Fixed by #8520
Assignees
Labels

Comments

@jigsawye
Copy link

jigsawye commented Dec 8, 2023

Describe the bug

The string compression output for escape(\) is not as expected. This bug was not present in 1.3.97 but started occurring after 1.3.98.

Input code

const a = '\\';
const b = `${a}`;

console.log(b)

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "loose": false,
    "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
      }
    },
    "target": "es2022"
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.98&code=H4sIAAAAAAAAA0vOzysuUUhUsFVQj4lRt%2BZKBvOTgPwElerE2gRrLrBQfk6qXk5%2BukaSJgBb5y21MQAAAA%3D%3D&config=H4sIAAAAAAAAA32UO3LjMAxA%2B5zCozrFjostcoDtcgYOLYIyshShIUDHmozvvtDHXieG3El4%2BBG%2Fr5fdrvngtnnbfemn%2Fgy%2BMJTbv0p4zOLPKmlkHIDbgoM0r1cqPKHoE8MsuiykSUQMV7LKeswYx3vfLfVDAeY7mUp96WoPWfi7%2FcoKfU5ASr2XH4gS%2BPyEOM8Os0AHxXLcUkp%2BYHAnXwwvU6a%2BIJMVYoJVILih0GDyHFCQssZ8pAF8cC0FMBAWaAVPYJlpLDXLrM8z3jPjAIfadXM%2Ff1jDyafqxYgJ57klmq3h9UjI4mLNVgkXuFGDBa7F%2FWmJ0RWQWvKj3Qdh3ujJXwCtQPLM2fdg%2BZ01os7TlnV8aok56sjKaHCdb%2BuVGTotqkOMRmWnykARtLpZINQWpsq2Vjor3igfYwAHMeqsGK75E6U9WkGnhaZoAO2vj9ZULcDdtnCDTwvxBP%2FRV4o9YKtG7%2BW4TXnsD5SeBOhBjhSeKGgrhLZx0StxHrZ5zQF0NCCYKpVn8HgEdAGEXAKxZkPXQz26LtHh%2F5lYFS7fbqvoQM8%2BGuD9r%2F2%2BeVlZ01Oo8zVYr%2FnU4EXv953S9QzfMm%2BQ36%2BWc9TLP4kAIlsZBgAA

SWC Info output

No response

Expected behavior

console.log("\\");

Actual behavior

console.log("\\\\");

Version

1.3.98

Additional context

After upgrading to Next.js 14.0.4, this bug was discovered.

@swc-bot
Copy link
Collaborator

swc-bot commented Feb 18, 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 Feb 18, 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