You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the input code has an object destructuring pattern with the object that has a setter with same parameter name,
then the variable is unnecessarily renamed in the output code.
I know that renaming variables will be okay in most cases, but it would be better to avoid such cases as much as possible, because there are some cases where renaming variable could results in inconsistent behavior, like accessing global variable using property access to globalThis.
I am using V8 engine to demonstrate the expected result instead of NodeJS.
Since NodeJS is not an engine but a runtime, the behavior of this in NodeJS does not follow ECMAScript specification.
The value of globalThis.x in the input code is 0:
$ d8V8 version 10.9.0
$ d8 input.js0
Actual behavior
The variable x is renamed to _$x, and the value of globalThis.x in the output code is undefined:
$ d8 output.jsundefined
Version
1.3.14 (default SWC playground)
Additional context
No response
The text was updated successfully, but these errors were encountered:
Describe the bug
When the input code has an object destructuring pattern with the object that has a setter with same parameter name,
then the variable is unnecessarily renamed in the output code.
I know that renaming variables will be okay in most cases, but it would be better to avoid such cases as much as possible, because there are some cases where renaming variable could results in inconsistent behavior, like accessing global variable using property access to
globalThis
.Input code
Config
No response
Playground link
https://play.swc.rs/?version=1.3.14&code=H4sIAAAAAAAAAytLLFKoVqhQsFUwUKgFktUKxaklCpUKGkAxTSCvVkEHiK25kvPzivNzUvVy8tM10nPykxJzQjIyi%2FUqNK0BODYeDEIAAAA%3D&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU%2FMMKZAOKZZcVTNf6tKEXagYUeScdiiyd%2BZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc%2F0N7G%2FHPynaLySe0Cj9ke9LUAAAA%3D
Expected behavior
I am using V8 engine to demonstrate the expected result instead of NodeJS.
Since NodeJS is not an engine but a runtime, the behavior of
this
in NodeJS does not follow ECMAScript specification.The value of
globalThis.x
in the input code is0
:Actual behavior
The variable
x
is renamed to_$x
, and the value ofglobalThis.x
in the output code isundefined
:Version
1.3.14 (default SWC playground)
Additional context
No response
The text was updated successfully, but these errors were encountered: