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
Adding a comment to a parantheses wrapped return evaluation with embedded comment ends up stripping the wrapping parantheses and breaking the return evaluation.
Input code
conststring1={errorCode: 'test'};conststring2='test';functionevaluateWithoutComment(){returnstring1.errorCode===string2;}functionevaluateWithComment(){return(// This comment doesn't break return evaluationstring1?.errorCode===string2);}functionevaluateWithCast(){return((string1as{errorCode: string})?.errorCode===string2);}functionevaluateWithCastAndComment(){return(// This comment seems to cause wrapping parantheses to get stripped, breaking the return evaluation(string1as{errorCode: string})?.errorCode===string2);}// Works, returns trueconsole.log(`evaluateWithoutComment: ${evaluateWithoutComment()}`);// Works, returns trueconsole.log(`evaluateWithComment: ${evaluateWithComment()}`);// Works, returns trueconsole.log(`evaluateWithCast: ${evaluateWithCast()}`);// Breaks, returns undefined due to stripped paranthesesconsole.log(`evaluateWithCastAndComment: ${evaluateWithCastAndComment()}`);
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
Adding a comment to a parantheses wrapped return evaluation with embedded comment ends up stripping the wrapping parantheses and breaking the return evaluation.
Input code
Config
Playground link
https://play.swc.rs/?version=1.3.89&code=H4sIAAAAAAAAA6WSwW6DMBBE73zFHioBUpSoPQahqs0vVMo1Lt4ACtjIXrcHxL%2FXGNzS1kRqc7Ps4e0wO4UUmkCTqkV5Dzn0gEpJdZAc9xATaophyKJiIXuwsukli6KzEQXVUgC%2BscYwwmNNlTR0kG2LgpIU%2BghAIRkl%2FJjt5wjI89xTs2hYwQVZCdgzwG4HL1WtoZg0wCVqERO8KmQXr51hluu%2BmW08hn1YSXrFC9M%2FjThm4iNk%2BnuG0z0M6b%2FHPQkeTiAYgEZsNZCEghmN8K5Y140GOqaYoAo1utcSp3V2HfLNlNaosoKV0G7%2FQev0KNVFb%2BYJ1ocy6KolG9w2skxO4Rbt4a5f69dwsvS%2Fole4N0Ltrn4RXV087nmMecEzguO5FsiBGxy34jey3Nb1gV%2FlCI1eVseZ%2BADOKfkp7wMAAA%3D%3D&config=H4sIAAAAAAAAA1WPPQ6DMAyF954CeaYSpVvv0LV7FEwVROLINlIR4u5NoEF0s997n3%2BWS1XBIBYe1ZLK1CibID2xP6QkdmiJjRK%2FkMVRSB60TdtemztsmbXe6WhYkM%2BozEHNJwM6RxTLLirUxVXJVm9Gwb85aviNmimUtOj2I2AkEixE1jYAPHXTiKcn0qoMW%2FKewiBwJJ08S1Z5wp12wfXzccf6BfgI7zMVAQAA
SWC Info output
No response
Expected behavior
The wrapped parantheses are preserved so that the return evaluation evaulates to
true
similar to the other cases.Actual behavior
As can be seen in
evaluateWithCastAndComment
, the stripped parantheses end up returningundefined
.Version
1.3.89
Additional context
No response
The text was updated successfully, but these errors were encountered: