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

Typeof This of Symbol().getTypeof Error #2865

Open
clhiker opened this issue Nov 24, 2021 · 0 comments
Open

Typeof This of Symbol().getTypeof Error #2865

clhiker opened this issue Nov 24, 2021 · 0 comments

Comments

@clhiker
Copy link

clhiker commented Nov 24, 2021

Describe the bug

In the poc.js, when running the transformed by swc by node, it's

symbol
symbol

but it should be

object
symbol

When rewriting typeof, it may contain a bug.

Input code

Object.prototype.getTypeof = function () {
    return typeof this;
}

console.log(Symbol().getTypeof())
console.log(typeof Symbol())

Config

{
  "jsc": {
    "parser": {
      "syntax": "ecmascript",
      "jsx": false,
      "dynamicImport": false,
      "privateMethod": false,
      "functionBind": false,
      "exportDefaultFrom": false,
      "exportNamespaceFrom": false,
      "decorators": false,
      "decoratorsBeforeExport": false,
      "topLevelAwait": false,
      "importMeta": false
    },
    "transform": null,
    "target": "es5",
    "loose": false,
    "externalHelpers": false
  }
}

Playground link

https://play.swc.rs/?version=1.2.112&code=H4sIAAAAAAAAA/NPykpNLtErKMovyS+pLEjVS08tCQHS+WkKtgpppXnJJZn5eQoamgrVXApAUJRaUlqUp1ACUVGSkVlszVXLxZWcn1ecn5Oql5OfrhFcmZuUn6OhiTBJQ1MTRQVUN0yhJgCxkh48hAAAAA==&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU/MMKZAOKZZcVTNf6tKEXagYUeScdiiyd+ZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc/0N7G/HPynaLySe0Cj9ke9LUAAAA=

Expected behavior

When typeof this of Symbol(), it should be object instead of symbol.

Version

1.2.112

Additional context

I run swc use cmd as follows

npx swc --config-file=.swcrc poc.js -o poc.js

The environment is ubuntu 20.04 amd64.

@clhiker clhiker added the C-bug label Nov 24, 2021
@kdy1 kdy1 modified the milestones: v1.2.113, v1.2.114, v1.2.115, v1.2.116 Nov 24, 2021
@kdy1 kdy1 modified the milestones: v1.2.116, v1.2.117, v1.2.118, v1.2.119 Dec 1, 2021
@kdy1 kdy1 modified the milestones: v1.2.119, v1.2.120, v1.2.121 Dec 10, 2021
@kdy1 kdy1 modified the milestones: v1.2.121, v1.2.122, v1.2.123, v1.2.124 Dec 19, 2021
@kdy1 kdy1 modified the milestones: v1.2.124, v1.2.125, v1.2.126, v1.2.127 Dec 29, 2021
@kdy1 kdy1 modified the milestones: v1.2.138, v1.2.139, v1.2.140, v1.2.141 Feb 8, 2022
@kdy1 kdy1 modified the milestones: v1.2.145, v1.2.146, v1.2.147, v1.2.148 Feb 24, 2022
@kdy1 kdy1 modified the milestones: v1.2.148, v1.2.149, v1.2.150 Mar 4, 2022
@kdy1 kdy1 added this to the Planned milestone Mar 12, 2022
@kdy1 kdy1 assigned kdy1 and unassigned kdy1 May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants