Skip to content

Parser rejects async used as a binding name or called as a function #5551

Description

@Shine-neko

async is only a reserved word in specific contexts; as a plain identifier it is valid, and V8/Node accept it. The parser currently rejects two such cases:

// 1. calling a function named `async`
function async(cb) { return cb; }
async(1);            // SyntaxError: expected token 'identifier', got '1'

// 2. binding named `async`
const async = 5;     // SyntaxError: abrupt end
async;

These already work, so async is accepted as a property/method name but not as a binding or a call target:

const o = { async: 1 }; o.async;      // ok
const o = { async() {} }; o.async();  // ok

This isn't purely academic: the widely used asynckit package (a transitive dependency of axios, form-data, …) calls a function it names async, so loading axios fails with the error above.

Possibly a regression or an uncovered case from #2275 / #2936, which added async-as-identifier support.

Environment: boa_engine main at commit 39cd112.

Activity

  1. Basharkhan7776 commented on Oct 4, 2026

    @Basharkhan7776

    Hi! I'd like to work on this issue.

    Diagnosis

    In ECMAScript, async is a contextual keyword rather than a reserved word. Currently, when boa_parser encounters async followed by (, it eagerly assumes an AsyncArrowFunction parameter list. Because of this, argument expressions like async(1) fail with a SyntaxError (expecting formal parameter identifiers) instead of resolving via CoverCallExpressionAndAsyncArrowHead into a normal CallExpression.

    Proposed Fix

    1. Update boa_parser's expression parsing so async(...) correctly falls back to a CallExpression if it is not followed by [no LineTerminator] =>.
    2. Add regression tests covering contextual identifier calls like async(...), variable declarations (const async = ...), and valid/invalid async arrow head disambiguation.

    Could you please assign this to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions