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 error location #3845

Closed
ghost opened this issue Jul 25, 2024 · 3 comments
Closed

Wrong error location #3845

ghost opened this issue Jul 25, 2024 · 3 comments

Comments

@ghost
Copy link

ghost commented Jul 25, 2024

Many places the error location is wrong and point to wrong char / symbol. I think most of the failing cases are affected.

let {b, b} = {}; report 4th char as the position of b, but that's is a whitespace, but point at {. The second b has also wrong pos reported

Other example

var x = a; const x = b;

([a]) => { const a = 0; }

E.g in this case it point to correct symbol, but the position is wrong.

let x = a; function x(){};

var x; let x;

([foo], [foo]) => {}

In this case the loc points at the generator pos and not the symbol

{ function *foo() {}; function *foo() {}; }

This case is messed up

[...0,a]=0

Repository owner deleted a comment from code30x58 Jul 25, 2024
@evanw
Copy link
Owner

evanw commented Jul 25, 2024

Thanks for the report. As best I can tell, this was a regression that was introduced in version 0.18.7. That release added support for TypeScript's using declarations which affects variable declarations, so that's likely the cause of the regression.

Edit: Specifically during the refactoring in 69a0c80, there's one spot where binding.Loc should have been replaced with loc instead of being left as binding.Loc.

@ghost
Copy link
Author

ghost commented Jul 25, 2024

Here are examples that doesn't relate to decl

foo[...x];

[...{a: 0} = c]

@evanw
Copy link
Owner

evanw commented Jul 25, 2024

I have tried out all of the cases you mention in the esbuild playground. The links to each case are below.

These ones look wrong, and are a result of the regression I mentioned earlier:

These ones look correct to me:

  • let x = a; function x(){}; (link)
  • var x; let x; (link)
  • ([foo], [foo]) => {} (link)
  • { function *foo() {}; function *foo() {}; } (link)
  • [...0,a]=0 (link)

Please let me know if there is additional information necessary to reproduce the problem for the ones that look correct to me.

@evanw evanw closed this as completed in 78f89e4 Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant