Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not allowed to await non-async chain #29

Open
coolaj86 opened this issue Mar 11, 2022 · 0 comments
Open

Not allowed to await non-async chain #29

coolaj86 opened this issue Mar 11, 2022 · 0 comments
Assignees
Labels
syntax the strict subset of JavaScript that is AJScript

Comments

@coolaj86
Copy link
Collaborator

coolaj86 commented Mar 11, 2022

Each await chain MUST be on its own line.

An "await chain" is

  • any statement that starts with await
    and terminates when
  • the result of a return is not a promise
  • (or when it's the end of the line).

Bug

Intuitively you'd think these should work as await signals that the interpreter should resolve all promises in the chain... but 'tis not so!

// error, oppsSync is not a property of the return value
let foo = await buildAsyncChain().buildMore().oopsSync().result;

// same as above
let bar = await doAsyncStuff().oopsSync().asyncMore();

Good Example

This is the desired, non-buggy behavior:

let fooPartial = await buildAsyncChain().buildMore().asyncStuff();
let foo = stuff.oopsSync().result;

let barPartial = await doAsyncStuff();
let bar = await barPartial.oopsSync().asyncMore();

Bad Example

let foo = (await doSyncStuff().asyncStuff()).oopsSync();

let bar = await (await doAsyncStuff()).oopsSync().asyncMore();
@coolaj86 coolaj86 added the syntax the strict subset of JavaScript that is AJScript label Mar 11, 2022
@wmerfalen wmerfalen self-assigned this Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
syntax the strict subset of JavaScript that is AJScript
Projects
None yet
Development

No branches or pull requests

2 participants