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

Passing objects in await expressions in REPL #10422

Open
hbibel opened this issue Apr 21, 2024 · 2 comments
Open

Passing objects in await expressions in REPL #10422

hbibel opened this issue Apr 21, 2024 · 2 comments
Labels
bug Something isn't working confirmed bug We can reproduce this issue repl An issue with `bun repl`

Comments

@hbibel
Copy link

hbibel commented Apr 21, 2024

What version of Bun is running?

1.1.4+fbe2fe0c3

What platform is your computer?

Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 x86_64

What steps can reproduce the bug?

  1. Start bun repl
  2. Define or import a function that takes an object as an argument and returns a promise, e.g. function foo({x: boolean}) { return Promise.resolve(123) }
  3. Invoke that function with await, e.g. await foo({x: true})

What is the expected behavior?

The function is evaluated without any issues

What do you see instead?

Bun REPL reports:

SyntaxError: Unexpected keyword 'return'. Expected '}' to end an object literal.

Additional information

No response

@hbibel hbibel added the bug Something isn't working label Apr 21, 2024
@Electroid Electroid added the repl An issue with `bun repl` label Apr 22, 2024
@SrBrahma
Copy link

Also happens here. Funnily, if you do const x = foo({x: true}) and await x, it works. The issue is having them on the same line.

@RiskyMH
Copy link
Contributor

RiskyMH commented Nov 20, 2024

The issue lies with the bun-repl package. If you have an object (ie {a:1}) and await in same input, it transpiles it weirdly as it's not expecting it to be muli-line indented.

Image
https://github.com/jhmaster2000/bun-repl/blob/47fcb4135b49662647d7848e58e15d73eb28fa6d/src/repl.ts#L531-L543

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue repl An issue with `bun repl`
Projects
None yet
Development

No branches or pull requests

4 participants