Skip to content

thenables not invoked from async arrow functions #4116

@kzc

Description

@kzc
  • Rollup Version: rollup v2.50.5
  • Operating System (or Browser): n/a
  • Node Version (if applicable): node v16.1.0

Async arrows were not covered in #4115.

Repro

$ cat async-then.js 
// async function
(async function () {
    return {
        get then() {
            return () => effect(11);
        }
    };
})();
// async arrow with block
(async () => {
    return {
        get then() {
            return () => effect(12);
        }
    };
})();
// async arrow without block
(async () => ({
    get then() {
        return () => effect(13);
    }
}))();
const effects = [], effect = x => effects.push(x);
Promise.resolve({
    then(resolve) {
        resolve({
            then(resolve) {
                console.log(effects.join(" "));
            }
        });
    }
});

Expected Behavior

$ cat async-then.js | node
11 12 13

Actual Behavior

$ cat async-then.js | rollup --silent | node
11
$ cat async-then.js | rollup --silent
// async function
(async function () {
    return {
        get then() {
            return () => effect(11);
        }
    };
})();
const effects = [], effect = x => effects.push(x);
Promise.resolve({
    then(resolve) {
        resolve({
            then(resolve) {
                console.log(effects.join(" "));
            }
        });
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions