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

Invalid code with comment inside arrow function returning an object #2814

Closed
metrip opened this issue Jan 11, 2023 · 2 comments
Closed

Invalid code with comment inside arrow function returning an object #2814

metrip opened this issue Jan 11, 2023 · 2 comments

Comments

@metrip
Copy link

metrip commented Jan 11, 2023

Possibly related to: #2805

Invalid code is produced when a comment is placed after an open parenthesis, in an arrow function returning an object:

➜ npx esbuild --version
0.16.16

➜ cat test.js
const foo = () => (
  // comment
  {
    x: 1,
  }
);

➜ npx esbuild test.js
"use strict";
const foo = () => // comment
{
  x: 1
};
@evanw
Copy link
Owner

evanw commented Jan 11, 2023

Thanks for the report. Will fix.

Looks like there's another case as well:

for ((/* foo */ let).x of y) ;

This incorrectly becomes:

for (/* foo */
let.x of y)
  ;

@clydin
Copy link

clydin commented Jan 11, 2023

With 0.16.16, I think i'm seeing another case also:

function *test() {
    yield (/* foo */function () {}());
}

Becomes:

function* test() {
  yield /* foo */
  function() {
  }();
}

@evanw evanw closed this as completed in 6346398 Jan 11, 2023
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

3 participants