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
The bar constant is defined inside the try block, rendering it inaccessible to the function baz, which is defined outside of the try block. This results in a ReferenceError at runtime.
Version
1.3.90
Additional context
When target is ES5, this actually works correctly, due to the const being transformed to a var.
As a point of comparison, TSC transpiles this with a var bar; statement outside of the try, even when target is set above ES5.
The text was updated successfully, but these errors were encountered:
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
SWC incorrectly handles the scope of declarations surrounding
using
declarations.Input code
Config
Playground link
https://play.swc.rs/?version=1.3.90&code=H4sIAAAAAAAAAyXIPQrAIAwG0D2n%2BEZdCj1AD6OiUggJRLO09O79G9%2FzsUtHU8UGcWaiojImcrJn1p%2FKdWHtIacjxEjUXMrcVfAFTgKsTrc3jK4b1lYZUlQAAAA%3D&config=H4sIAAAAAAAAA22PPQ7CMAyFd04ReWZAGRi4A4eIglsF5U%2B2K1FVvTtJ2hSQ2Oz3PdvPy0kpeLKFm1pKWZpsiJGOvig8RzGvooDMGdmSywLnToUrGoxnbNK6EfApMXaya8FFN8zfu20KmZD511itJo4e%2F24WQyNKzYOsL1q3LA1CSI%2BpTe3P1MCb8QofU09xXATH9z4pNBVtfQNyL9zVGQEAAA%3D%3D
SWC Info output
(N/A; reproduced using Deno / SWC playground)
Expected behavior
The transpiled program prints
1
.Actual behavior
The
bar
constant is defined inside thetry
block, rendering it inaccessible to the functionbaz
, which is defined outside of thetry
block. This results in aReferenceError
at runtime.Version
1.3.90
Additional context
When
target
isES5
, this actually works correctly, due to theconst
being transformed to avar
.As a point of comparison, TSC transpiles this with a
var bar;
statement outside of thetry
, even whentarget
is set aboveES5
.The text was updated successfully, but these errors were encountered: