oven-sh / bun

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

"Cannot destructure argument" error is hard to understand #10228

Open Dimava opened 3 months ago

Dimava commented 3 months ago

What version of Bun is running?

1.1.3+2615dc742

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

function foo({ a }) {
  return a
}
foo(null)

What is the expected behavior?

Anything that does not say "Right side of assignment". I spent a minute looking for the assignment

Here's what V8 gives:

Uncaught TypeError: Cannot destructure property 'a' of 'object null' as it is null.
    at foo (<anonymous>:1:16)
    at <anonymous>:4:1

What do you see instead?

1 | function foo({ a }) {
                        ^
TypeError: Right side of assignment cannot be destructured
      at foo (D:\projects\test\err.ts:1:21)
      at D:\projects\test\err.ts:4:1

Additional information

No response

Jarred-Sumner commented 3 months ago

This is a JavaScriptCore bug unfortunately. Would you be able to file an issue on WebKit's bug tracker in the JavaScriptCore category?