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

await should work in REPL #3700

Closed
ry opened this issue Jan 17, 2020 · 4 comments · Fixed by #7784
Closed

await should work in REPL #3700

ry opened this issue Jan 17, 2020 · 4 comments · Fixed by #7784
Labels
bug Something isn't working correctly repl related to the Read-Eval-Print-Loop functionality of Deno

Comments

@ry
Copy link
Member

ry commented Jan 17, 2020

> await Deno.permissions.query({ name: "read" })
error: Uncaught SyntaxError: await is only valid in async function
► <unknown>:1:1
    at evaluate ($deno$/repl.ts:84:34)
    at replLoop ($deno$/repl.ts:175:13)
@ry ry added the bug Something isn't working correctly label Jan 17, 2020
@kevinkassimo
Copy link
Contributor

Node seems to be using a (async () => { ${src} })() wrapper for this. But they also explicitly used a JS parser to ensure that there is no top-level return along with this await (which breaks the wrapper)

@lucacasonato
Copy link
Member

TLA only works in V8 module contexts - because the REPL is a traditional script context it can't do TLA.

Same root cause as #1285. (#1285 (comment)) - if the REPL will move to a module context, which would be nice, this would work out of the box. For now we could do the same as chrome dev tools and node which both just wrap the call in an async function.

@kitsonk
Copy link
Contributor

kitsonk commented Jan 21, 2020

if the REPL will move to a module context, which would be nice, this would work out of the box

I think that would be hard, because a module needs to be "closed" so its imports and exports and be analysed. It would effectively need to rerun the whole "module" every time a line is added. Only script contexts can really be open-ended like that, which means a few things have to be frigged.

@kevinkassimo
Copy link
Contributor

if the REPL will move to a module context, which would be nice, this would work out of the box

I think that would be hard, because a module needs to be "closed" so its imports and exports and be analysed. It would effectively need to rerun the whole "module" every time a line is added. Only script contexts can really be open-ended like that, which means a few things have to be frigged.

Yeah. And running a module again and again might yield unexpected repeated side effects (e.g. console.log multiple times)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly repl related to the Read-Eval-Print-Loop functionality of Deno
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants