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

Incorrect hoisting of functions with top level awaits in REPL #39744

Closed
DonJayamanne opened this issue Aug 12, 2021 · 1 comment
Closed

Incorrect hoisting of functions with top level awaits in REPL #39744

DonJayamanne opened this issue Aug 12, 2021 · 1 comment
Labels
repl Issues and PRs related to the REPL subsystem.

Comments

@DonJayamanne
Copy link
Contributor

Version

16.5.0

Platform

Darwin DESKTOP-239BQMO.corp.microsoft.com 20.6.0 Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:27 PDT 2021; root:xnu-7195.141.2~5/RELEASE_ARM64_T8101 x86_64

Subsystem

No response

What steps will reproduce the bug?

  • Start node repl with experimental top level await
    node --experimental-repl-await
  • Run the following code in the REPL
    foo(); const x = await Promise.resolve(1); function foo() { console.log('Do Something');}
    The following error is displayed
Uncaught TypeError: foo is not a function
    at REPL1:1:32

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior?

Function foo should be hoisted and available.

What do you see instead?

Repl errors out.

Additional information

No response

@targos targos added the repl Issues and PRs related to the REPL subsystem. label Aug 12, 2021
@DonJayamanne
Copy link
Contributor Author

I believe I have a solution (see PR, currently WIP here #39745).

targos pushed a commit that referenced this issue Aug 22, 2021
PR-URL: #39745
Fixes: #39744
Reviewed-By: Guy Bedford <guybedford@gmail.com>
targos pushed a commit that referenced this issue Sep 4, 2021
PR-URL: #39745
Fixes: #39744
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants