GPTScript / AiScript

A Minimal, Full-Stack, Tool-Assisted Language. Native to Browsers and Bun. Strictly & Strongly-Typed.
https://github.com/GPTScript/AiScript
Mozilla Public License 2.0
9 stars 1 forks source link

Not allowed to await non-async chain #29

Open coolaj86 opened 2 years ago

coolaj86 commented 2 years ago

Each await chain MUST be on its own line.

An "await chain" is

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();