Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: Assignment operator to property of this in arrow async function #6334

Open
p51lee opened this issue Nov 2, 2022 · 0 comments
Open
Labels

Comments

@p51lee
Copy link

p51lee commented Nov 2, 2022

Describe the bug

Final value of x in the input code is expected to be 1, but is 0 in the output code.
In the output code, the += operator is performed on variable _ so the value of x does not change.

Input code

var x = 0;
var f = async () => {
  this . x += await 1 ;
  console.log(x);
}
f();

Config

No response

Playground link

https://play.swc.rs/?version=1.3.11&code=H4sIAAAAAAAAAytLLFKoULBVMLDmKgMy04DMxOLKvGQFDU0FWzuFai4FhZKMzGIFPaAqbaBceWJmiYKhgjVQPDk%2Frzg%2FJ1UvJz9do0LTmquWK00DSKEJAwBHDG6mYQAAAA%3D%3D&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU%2FMMKZAOKZZcVTNf6tKEXagYUeScdiiyd%2BZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc%2F0N7G%2FHPynaLySe0Cj9ke9LUAAAA%3D

Expected behavior

I am using V8 engine to demonstrate the result instead of NodeJS.
Since NodeJS is not an engine but a runtime, the behavior of this in NodeJS does not follow ECMAScript specification.

Final value of x in the input code is 1:

$ d8
V8 version 10.9.0
$ d8 input.js
1

Actual behavior

$ d8 output.js
0

Version

1.3.11 (default SWC playground)

Additional context

No response

@p51lee p51lee added the C-bug label Nov 2, 2022
@kdy1 kdy1 added this to the Planned milestone Nov 3, 2022
@kdy1 kdy1 self-assigned this Nov 3, 2022
@kdy1 kdy1 removed their assignment Nov 24, 2022
@kdy1 kdy1 removed this from the Planned milestone Jan 17, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Development

No branches or pull requests

2 participants