swc
swc copied to clipboard
Await is not a keyword in script mode
Describe the bug
SWC would still treat input as top level await enabled even if source is script.
Input code
var await = () => {
}
await(2)
Config
No response
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.3.100&code=H4sIAAAAAAAAAytLLFJILE%2FMLFGwVdDQVLC1U6jm4qrl4gKLaRhpAgBOvX7AIAAAAA%3D%3D&config=H4sIAAAAAAAAA1WPSw7DIBBD9zkFmnW33fQOPQSik4iInzCViqLcvUAgbXbYfmOLbRKCVih6iK08iwgyguOpi4PskvwUh1hZCRV1SHQb6YoazdKAm7UfCSUZF07tCveOk%2FEePPDuWe30nP8HlbchMnAFKyrdYvg6N%2FVJsv71bmH%2FSMqhqtpmvVtBP3Isnu2k8RznR%2Ff%2BBaNtxkwaAQAA
SWC Info output
No response
Expected behavior
Should not error.
Actual behavior
x top level await is only allowed in module ,-[input.js:2:1] 2 | 3 | } 4 | 5 | await(2) : ^^^^^ `----
Version
latest
Additional context
No response
Some JS parser also treat it as keyword, for example "https://astexplorer.net/"