-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Bug]: Re-assignment to class during static field initialization #6307
Comments
I have also submitted a bug report to babel: babel/babel#15000 |
I believe swc should report error in this case -- swc reject const reassignment, although it is valid JS. Or we could drop const reassignment lint, that would also make swc consistent. |
I think we should catch this too. We should move hard errors to compile time as much as possible |
I'm a bit cautious about this -- const reassignment is not "hard error", it's runtime error try {
const a = 1
a = 2
} catch (e) {
console.log(e)
} But I don't believe anyone would rely on this. |
Oh, you are right... But same here. I don't expect people to rely on it |
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. |
Describe the bug
Mutable assignment to class name should throw
TypeError
during an initialization of static fields.However, the transpiled code terminates without any error.
Input code
Config
No response
Playground link
https://play.swc.rs/?version=1.3.11&code=H4sIAAAAAAAAA0vOSSwuVqhQqFYoLkksyUxWqFSwBXJtFQwUrBVqFQB8P0%2FWHwAAAA%3D%3D&config=H4sIAAAAAAAAA0WMTQrEIAxG75K1286id5hDBCctFv9IUhgR714tlu7C915ehUMsrBUyshCPS0pU%2FMMKZAOKZZcVTNf6tKEXagYUeScdiiyd%2BZSEJjUQXHRbGSWbQmYSeRHG3T9m66GQfucYKmjJdAc%2F0N7G%2FHPynaLySe0Cj9ke9LUAAAA%3D
Expected behavior
Mutable assignment to class name should throw
TypeError
during an initialization of static fields:Actual behavior
The output code terminates without any error.
Version
1.3.11 (default SWC playground)
Additional context
No response
The text was updated successfully, but these errors were encountered: