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 incrementing a private class field (using the hashtag-syntax) and the field is put inside parenthesis while the increment operator is outside the parenthesis, invalid JavaScript code is generated.
e.g.: ++(this.#n)
🔎 Search Terms
private hashtag field increment parenthesis
🕗 Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about private class fields and incrementing/decrementing
Bug Report
When incrementing a private class field (using the hashtag-syntax) and the field is put inside parenthesis while the increment operator is outside the parenthesis, invalid JavaScript code is generated.
e.g.:
++(this.#n)
🔎 Search Terms
private hashtag field increment parenthesis
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
The following code is generated:
which leads to the error:
invalid increment/decrement operand
when executing it, since the result of a function cannot be incremented/decremented.The compiler seems to think that the variable-reference expression is read-only because of the parenthesis.
🙂 Expected behavior
The parenthesis should be ignored by the compiler and the correct code needs to be generated:
The text was updated successfully, but these errors were encountered: