Compiler declares variable with let
causing ReferenceError when trying to access it before initialization
#8787
Labels
let
causing ReferenceError when trying to access it before initialization
#8787
Describe the bug
When trying to execute the compiled project it fails with
ReferenceError: Cannot access 'X' before initialization
. The reason is that the variable is declared usinglet
(not hoisted), so accessing it from the code above is forbidden.Input code
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.4.11&code=H4sIAAAAAAAAA02OwQ6CMBBE7%2F2KvQEJ%2FgAYg3qGk3dTYcEmW4rdElHDv9uWxHjb3ZmdN0pPxjr4CICzoVmPOVzkjTCHI5F5NjNRLlbordGQMD5mJPXGnXtNyK1Vk0tKIar4koYQF6ZGaiwgae%2FSXTUyywE58TGZwCXiWpLMcPZ6vcmAi8OxY6hNh3SSjPs%2F9RD7Vb9GaS%2BJMQu3rXREA%2FQKqfNg59M8D2ANnrAVwM6qcSjFKr54bfeu8wAAAA%3D%3D&config=H4sIAAAAAAAAA3VRPU%2FDQAzd%2Bysijwi10JEJCQaWsDEhBnNxSsp9yXakRlX%2FO3dpLk0Gprv33tnv2XfeVBUcxcBTdU7XBCKyEM84MTJ4xVNiQIdIYriLCvdFVclSi1Zo5hoygVEDS5KU%2B0m5XA9Q5ANpbkiyf9g%2FQuEZvbSB3dLd0gHN8Fo6%2Fu9Vk2KDipPlytGGILQuBTopsUf7RjbSmHSp%2FhLFF4si7%2BhoPcaof6PQB9s8xHYnbMoMEfVHlvmfd3cJft4qt4mY0Nc15GYKCi40vaXbX%2BR9ZwcTnAv%2BKDC%2FlNCzoRrjMhq4znftsJwEOqlL03Erlz%2FvHLIU8gEAAA%3D%3D
SWC Info output
Expected behavior
or to define properties at the end of a file.
Actual behavior
Version
1.4.11
Additional context
No response
The text was updated successfully, but these errors were encountered: