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

Minifier evaluates the code point of the character instead of char code for charCodeAt. #8943

Closed
hyp3rflow opened this issue May 10, 2024 · 0 comments · Fixed by #8946
Closed
Assignees
Labels

Comments

@hyp3rflow
Copy link
Sponsor Contributor

Describe the bug

Code point is differ from char code which is returned by String.prototype.charCodeAt.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt#description

Input code

"use strict";
const k = (() => {
    return "👨‍👩‍👦".charCodeAt(0);
})

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false
    },
    "target": "es5",
    "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
      },
      "mangle": false
    }
  },
  "module": {
    "type": "commonjs"
  },
  "minify": false,
  "isModule": false
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.5.5&code=H4sIAAAAAAAAA1MqLU5VKC4pykwuUbLmSs7PKy5RyFawVdDQ0FSwtVOo5lIAgqLUktKiPAWlD%2FMnrnjU0AukVkKoZUp6yRmJRc75KamOJRoGmtZctZoAAHg2xlIAAAA%3D&config=H4sIAAAAAAAAA32UO5LbMAyG%2Bz2FR3XaNDlAupyBQ5OgTIckNATotWbHdw%2F08CNrSJ2EDz9AAiC%2BPg6H7kyu%2B3X4kk%2F5GWwlqI9%2FsdBY2F7F0oHLllyNA3c%2F7vRMEwo2Ecym20I6trUHnlX0c3XvEiLB3X215VhiGF8TOsxDBaIXm1glXstQmP7Xr6zi5wS4tlf7ETGBLTvEWDKxMPRQtcAOU7IDgbnYqkSZTmprJNRSTLAxeDNUHFRefOSIRXK%2BUw%2FWG4ceFBQrOI4X0GSSS2SF5HrKfWbs4dj6fm7yNzVcbGqWlZxwnVsip1WinjASm9CKVsIFbtRggWtxvytjMBW41fKuO2MsGz35CyAVSJao2Axa3NkjyDxtqcOuMpYgI8ujwmW%2BtVsW6KWoJsagVHaqDFSOWjcr%2BOZgqqzTjrPijfJR9GAgBJkVJTR9RnYnLSmPA2BQgPTXBm2qFmAer3CDTw9iB%2F%2BWW7I%2BYKtHtnzapjTmI6adBBn4hH7HQVrBuI2rbInrsM1b8SCjAV51aTSD9yUgD4DRpHlZvs2GPA%2BJaPqEx%2BeaWB1ujyWcbemf733Zwx%2BrQ5fRtxmuG37q77SXpR0Zy5m6p%2Bd9FT9O30X6c5cvsW%2F%2FAHrujcQzBgAA

SWC Info output

No response

Expected behavior

the char code of the first character of "👨‍👩‍👦" is 55357.

Actual behavior

minifier evaluates it as 128104, which is the code point of the first character.

Version

1.5.5

Additional context

No response

@kdy1 kdy1 self-assigned this May 12, 2024
kdy1 added a commit that referenced this issue May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants