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

require-atomic-updates complains about unrelated variable references #11900

Closed
dohse opened this issue Jun 25, 2019 · 6 comments
Closed

require-atomic-updates complains about unrelated variable references #11900

dohse opened this issue Jun 25, 2019 · 6 comments
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue bug ESLint is working incorrectly rule Relates to ESLint's core rules

Comments

@dohse
Copy link

dohse commented Jun 25, 2019

Tell us about your environment

  • ESLint Version: 6.0.1
  • Node Version: 10.15.3
  • npm Version: 6.4.1

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
---
  extends: eslint:recommended
  parserOptions:
    ecmaVersion: 2017

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

async function f() {}

async function t() {
  for (const x of ['A', 'B', 'C']) {
    await f(x);
  }
  for (const x of ['A', 'B', 'C']) {
    await (() => f(x))();
  }
}

t();
> eslint atomic-updates.js

What did you expect to happen?

I get no error or a useful explanation what is wrong with this code.

What actually happened? Please include the actual, raw output from ESLint.

I am getting this linting error:

…/atomic-updates/atomic-updates.js
  7:3  error  Possible race condition: `const x` might be reassigned based on an outdated value of `const x`  require-atomic-updates

✖ 1 problem (1 error, 0 warnings)

Are you willing to submit a pull request to fix this bug?

I expect it to take me quiet long to understand the logic. Therefore not at this moment.

@dohse dohse added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jun 25, 2019
@hon2a
Copy link

hon2a commented Jun 25, 2019

I've just encountered a similar one:

try {
  result = await someAsyncCall(/* ... */)
} catch (e) {
  ctx.status = e.statusCode || 500
  ctx.body = e.error
  return
}

I'm getting an error for both of the assignment lines in the catch block:

[error] Possible race condition: `ctx.status` might be reassigned based on an outdated value of `ctx.status`. (require-atomic-updates)
[error] Possible race condition: `ctx.body` might be reassigned based on an outdated value of `ctx.body`. (require-atomic-updates)

@mysticatea mysticatea added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jun 25, 2019
@mysticatea
Copy link
Member

Thank you for your report.

I confirmed it. Looks like the initializer in for-of syntax was handled as an assignment.

@hon2a Your case looks different to this issue because it doesn't contain for-of syntax. And I couldn't reproduce it: online demo.

@hon2a
Copy link

hon2a commented Jun 25, 2019

@mysticatea: Sorry, here you go. Should I create a separate issue then?

@mysticatea
Copy link
Member

@hon2a Thanks. It looks the same issue as #11899.

@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that accepted issues failing to be implemented after 90 days tend to
never be implemented, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@nicolo-ribaudo
Copy link

Another demo case: demo

export let lock = 2;

export async function f() {
  {
    let lock;
    lock;
  }
  await null;
  lock = 3;
}

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 23, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Mar 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants