oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.04k stars 2.76k forks source link

Passing objects in await expressions in REPL #10422

Open hbibel opened 6 months ago

hbibel commented 6 months ago

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

SrBrahma commented 2 weeks ago

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.