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 false positive #11687

Closed
TheModMaker opened this issue May 8, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@TheModMaker
Copy link

commented May 8, 2019

May be related to #11194, but that looked more like naming conflicts.

Tell us about your environment

  • ESLint Version: 5.16.0
  • Node Version: 11.13.0
  • npm Version: 6.7.0

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

Please show your full configuration:

Configuration
module.exports = {
    "parserOptions": {
        "ecmaVersion": 2017
    },
    "rules": {
        "require-atomic-updates": "error",
    },
};

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

https://eslint.org/demo/#eyJ0ZXh0IjoiLyplc2xpbnQgcmVxdWlyZS1hdG9taWMtdXBkYXRlczogZXJyb3IgKi9cclxuXHJcbmFzeW5jIGZ1bmN0aW9uIGYoKSB7XHJcbiAgICB0cnkge1xyXG4gICAgICAgIHRoaXMuZm9vID0gZG9Tb21ldGhpbmcoKTtcclxuXHR9ICBjYXRjaCAoZSkge1xyXG4gICAgICAgIHRoaXMuZm9vID0gbnVsbDtcclxuICAgICAgICBhd2FpdCBkb0Vsc2UoKTtcclxuICAgIH1cclxufVxyXG4iLCJvcHRpb25zIjp7InBhcnNlck9wdGlvbnMiOnsiZWNtYVZlcnNpb24iOjgsInNvdXJjZVR5cGUiOiJtb2R1bGUiLCJlY21hRmVhdHVyZXMiOnt9fSwicnVsZXMiOnt9LCJlbnYiOnt9fX0=

async function f() {
  try {
    this.foo = doSomething();
  }  catch (e) {
    this.foo = null;
    await doElse();
  }
}

What did you expect to happen?
No errors.

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

foo.js
  5:5  error  Possible race condition: `this.foo` might be reassigned based on an outdated value of `this.foo`  require-atomic-updates

✖ 1 problem (1 error, 0 warnings)

The doSomething method is synchronous so it cannot violate this rule about using "await". I'm thinking it is confused about reassigning in the "catch" block, but for a synchronous method, that should be allowed and not violate this rule.

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

@mysticatea mysticatea added accepted rule and removed triage labels May 8, 2019

@mysticatea

This comment has been minimized.

Copy link
Member

commented May 8, 2019

Thank you for the report.

I have confirmed that #11224 fixes this issue also in fortune.

mysticatea added a commit that referenced this issue May 8, 2019

mysticatea added a commit that referenced this issue May 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.