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

Pipeline operator doesnt await properly #7480

Closed
dacz opened this issue Mar 3, 2018 · 10 comments
Closed

Pipeline operator doesnt await properly #7480

dacz opened this issue Mar 3, 2018 · 10 comments
Labels
Has PR i: invalid outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Pipeline Operator

Comments

@dacz
Copy link

dacz commented Mar 3, 2018

await in pipeline doesn't translate to working code as described in specs.

Input Code

const f1 = async x => x + 1;
const f2 = async x => Promise.resolve(x + 1);

// this is ok
const runOk = async () =>
  5 |> async(_) => await f1(_) |> async (_) => await f2(_);

runOk().then(v => console.log('runOk returns:', v));

// this will not await fir the results
const runFail = async () =>
  5 |> await f1 |> await f2;

runFail().then(v => console.log('runFail returns:', v))

repl

babel v7.0.0.-beta39

Expected Behavior

translates to

...
return _ref2 = (_3 = 5, (await f1)(_3)), (await f2)(_ref2);
...

should translate to

return _ref2 = (_3 = 5, (await f1(_3)), await f2(_ref2);
@babel-bot
Copy link
Collaborator

Hey @dacz! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@mAAdhaTTah
Copy link
Contributor

I'd be happy to take a look at this after we land #7458.

@nicolo-ribaudo
Copy link
Member

This will be fixed by #7154

@dacz
Copy link
Author

dacz commented Mar 6, 2018

@nicolo-ribaudo thanks. Do you have any idea when it will be released? You requested changes in #7154 in Jan and it is kind of stalled since then and with conflicts with master.

@mAAdhaTTah
Copy link
Contributor

So we're going to ban await in the basic, "minimal proposal" spec here: tc39/proposal-pipeline-operator#108 and solve await in each of the proposals we're working on currently working on. This is not going to be the final semantics of pipeline in any of the proposals, given the ambiguity between whether x |> await f becomes await f(x) or (await f)(x).

@dacz
Copy link
Author

dacz commented Mar 20, 2018

@mAAdhaTTah Thank for the note. I've read the conversations but it's not clear to me.

Pipeline operator (as part of the stage-1) will work but await will NOT be part of it (will throw). There will be (probably) two different plugins that will add the await functionality (as f# style or smart style) or one that will use flags to signalize the used style.

Do I understand it well? Thanks a lot.

@mAAdhaTTah
Copy link
Contributor

mAAdhaTTah commented Mar 20, 2018

Yes, although not "probably"; those two different plugins are in progress already, representing two different proposals for the pipeline operator. We're doing this to solicit feedback from the community on them.

Edit: Excuse me, one babel plugin, flags for the various "modes".

@mAAdhaTTah
Copy link
Contributor

I believe we can close this, as we banned await in the minimal and are working on implementing await properly in each of the proposals.

@js-choi
Copy link
Contributor

js-choi commented Jan 2, 2019

I dunno; maybe it’d be good to keep it open until we finish actually implementing it in them. It’s “in progress”, at least. But either way is probably fine.

@thiagoarrais
Copy link
Contributor

Given the current incarnation of the proposals, I think this may be closed with a WONTFIX.

IIRC, this input code is a syntax error both in smart as in f#:

 5 |> await f1 |> await f2;

And if we put parentheses around the await clause, f# will translate it to:

return _ref2 = (_3 = 5, (await f1)(_3)), (await f2)(_ref2);

Which doesn't seem to be the intention of the OP.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR i: invalid outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Pipeline Operator
Projects
None yet
Development

No branches or pull requests

6 participants