swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
31.26k stars 1.23k forks source link

`await` keyword is dropped when calling function named `using` #9688

Closed wgoehrig closed 3 weeks ago

wgoehrig commented 3 weeks ago

Describe the bug

I have an async function using, but swc is omitting the await keyword that precedes calls to using.

Input code

async function using(x) { /* do something... */ }
async function test() {
  await using();
}

Config

{
  "$schema": "https://swc.rs/schema.json",
  "jsc": {
    "parser": {
      "syntax": "ecmascript"
    },
    "target": "es2022"
  },
  "minify": false
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.7.40&code=H4sIAAAAAAAAA0ssrsxLVkgrzUsuyczPUygtzsxL16jQVKjm5VJQSM7PK87PSdXLyQeJWfNy1fJy8XIlomrJL8lILSJNS0lqcYkGVENieWJmCdRepbT8fCWQJpgwxGylpMQiJahZAEWBpXqwAAAA&config=H4sIAAAAAAAAA1VPOw7DIAzdOQXy3KFi6NA79BCIOhERBGQTqSjK3UsIpM3m9%2FOzVyElTGzgKdcyFhA1MdKJC8N5TvpTGEDjNRuyMcGtqxPv0qAdY6W2Q4GkacRUU6zuSrUEuBAYe6Jx3s52yP%2BdJvhIyHw17lY9jw6vjaK1gg%2FvpYrtl5QjHhc84GfqZedisPzqyUQLiu0LtK2NIRcBAAA%3D

SWC Info output

Operating System:
    Platform: linux
    Arch: x64
    Machine Type: x86_64
    Version: #1 SMP Wed Mar 2 00:30:59 UTC 2022
    CPU: (24 cores)
        Models: Intel(R) Core(TM) i9-9920X CPU @ 3.50GHz

Binaries:
    Node: 21.7.3
    npm: 10.5.0
    Yarn: N/A
    pnpm: 9.12.2

Relevant Packages:
    @swc/core: 1.7.40
    @swc/helpers: N/A
    @swc/types: N/A

SWC Config:
    output: N/A
    .swcrc path: N/A

Next.js info:
    output: N/A

Expected behavior

The await keyword should be preserved in the output, since using (expr) is a valid function call:

async function using(x) {}
async function test() {
    await using();
}

Actual behavior

The await keyword is omitted from the output:

async function using(x) {}
async function test() {
    using();
}

Version

1.7.40

Additional context

No response