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

10$: Warn on let ({x} = y); #1203

Closed
strager opened this issue Feb 21, 2024 · 6 comments
Closed

10$: Warn on let ({x} = y); #1203

strager opened this issue Feb 21, 2024 · 6 comments
Assignees
Labels
for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html good first issue Good for newcomers and C++ beginners

Comments

@strager
Copy link
Collaborator

strager commented Feb 21, 2024

Before refactor:

let x;
({x} = y);

After refactor:

let ({x} = y);  // Bug! This uses an undeclared variable 'x' and calls a function named 'let'.

Conditions for this diagnostic:

  • Function call with a variable let as the callee.
  • Exactly one function argument.
  • Function argument is an assignment expression with =.
  • Function argument's left-hand side is an object literal.
@strager strager added good first issue Good for newcomers and C++ beginners for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html labels Feb 21, 2024
@msharipov
Copy link
Contributor

msharipov commented Feb 23, 2024

@strager Shouldn't this be considered an error? Code like this crashes in Node.js on line 5:

const y = {x: 45, z: "helloworld"};
let z;
({z} = y);
console.log(z);
let ({x} = y);
console.log(x);

@strager
Copy link
Collaborator Author

strager commented Feb 24, 2024

@msharipov This doesn't crash:

const y = {x: 45, z: "helloworld"};
let z;
({z} = y);
console.log(z);

function let(arg) {
  console.log("let", arg);
}
let x;
let ({x} = y);
console.log(x);

@msharipov
Copy link
Contributor

@strager Ah, I see. Could you please assign this to me?

@Nyx1on
Copy link

Nyx1on commented Mar 2, 2024

I claim this for-hire task. I expect payment after I complete this task. I will email the quick-lint-js team if I am assigned this task.

@strager
Copy link
Collaborator Author

strager commented Mar 2, 2024

@Nyx1on Someone else already claimed this task. If @msharipov is unresponsive, I'll give the task you @Nyx1on.

@msharipov
Copy link
Contributor

I'm still working on this, it's just taking a while.

msharipov added a commit to msharipov/quick-lint-js that referenced this issue Mar 11, 2024
Added a new diagnostic E0719 that closes quick-lint#1203. Issues a warning when a
function let() is called on an object assignment expression.

quick-lint#1203
msharipov added a commit to msharipov/quick-lint-js that referenced this issue Mar 11, 2024
Added a new diagnostic E0719 that closes quick-lint#1203. Issues a warning when a
function let() is called on an object assignment expression.

quick-lint#1203
msharipov added a commit to msharipov/quick-lint-js that referenced this issue Mar 11, 2024
Added a new diagnostic E0720 that closes quick-lint#1203. Issues a warning when a
function let() is called on an object assignment expression.

quick-lint#1203
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html good first issue Good for newcomers and C++ beginners
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants