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

Certain syntax errors have poor position recovery #833

Open
nmain opened this issue Mar 29, 2024 · 0 comments
Open

Certain syntax errors have poor position recovery #833

nmain opened this issue Mar 29, 2024 · 0 comments

Comments

@nmain
Copy link

nmain commented Mar 29, 2024

With the following Javascript code:

(() => {
    <div>This div has no end
})();

Babel gives an expected error message:

/sample.js: Unterminated JSX contents. (2:9)

  1 | (() => {
> 2 |     <div>This div has no end
    |          ^
  3 | })();

But Sucrase is less helpful:

Error transforming sample.js: Unexpected token, expected "," (1:5)

An extra comma at line 1 col 5? I don't quite understand that.

Playground link

If a non-arrow function is used, Sucrase does give a good result:

(function() {
    <div>This div has no end
}).call(this);
Error transforming sample.js: Unterminated JSX contents (2:10)

Playground link

This isn't an important bug to me, as bad syntax is bad syntax. But I'm reporting this because it did work as I'd expect on Sucrase 3.16, so maybe it's something that can be easily fixed.

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