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

wrong line number for error "Right side of assignment cannot be destructured" #14700

Open
hrgdavor opened this issue Oct 20, 2024 · 1 comment
Labels
bug Something isn't working runtime transpiler parser || printer

Comments

@hrgdavor
Copy link

hrgdavor commented Oct 20, 2024

What version of Bun is running?

1.1.31+e448c4cc3

What platform is your computer?

No response

What steps can reproduce the bug?

run a simple script err.js:

let obj
let {id} = obj

What is the expected behavior?

report error on line 2

What do you see instead?

error reported on line 1

Additional information

as expected issue is the same on linux and windows.

@hrgdavor hrgdavor added bug Something isn't working needs triage labels Oct 20, 2024
@guest271314
Copy link
Contributor

If you wrap the code in try..catch you'll get the correct line number

bun run test.js
      at /home/user/bin/test.js:5:11
1 | try {
2 |   let obj
3 |   let {id} = obj
4 | } catch (e) {
5 |   console.log(e);
      ^
TypeError: Right side of assignment cannot be destructured
      at /home/user/bin/test.js:5:3
deno -A test.js
TypeError: Cannot destructure property 'id' of 'obj' as it is undefined.
    at file:///home/user/bin/test.js:3:8
node test.js
TypeError: Cannot destructure property 'id' of 'obj' as it is undefined.
    at Object.<anonymous> (/home/user/bin/test.js:3:8)
    at Module._compile (node:internal/modules/cjs/loader:1568:14)
    at Object..js (node:internal/modules/cjs/loader:1711:10)
    at Module.load (node:internal/modules/cjs/loader:1328:32)
    at Function._load (node:internal/modules/cjs/loader:1138:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
    at node:internal/main/run_main_module:36:49

@nektro nektro added transpiler parser || printer runtime and removed needs triage labels Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working runtime transpiler parser || printer
Projects
None yet
Development

No branches or pull requests

3 participants