Skip to content
Permalink
Browse files

[[FIX]] Warn on reassignment of async functions

Correct typo to promote consistency in enforcement of linting rule.
  • Loading branch information...
jugglinmike authored and rwaldron committed Feb 16, 2019
1 parent b0c224b commit 14384d34fac833b8efc671be19e70489f78d0194
Showing with 15 additions and 1 deletion.
  1. +1 −1 src/scope-manager.js
  2. +14 −0 tests/unit/parser.js
@@ -345,7 +345,7 @@ var scopeManager = function(state, predefined, exported, declared) {

isFunction = usedLabelType === "function" ||
usedLabelType === "generator function" ||
usedLabelType === "async fuction";
usedLabelType === "async function";

// check for re-assigning a function declaration
if ((isFunction || usedLabelType === "class") && usage["(reassigned)"]) {
@@ -7079,6 +7079,20 @@ exports.functionReassignment = function (test) {
.addError(10, 3, "Reassignment of 'h', which is a function. Use 'var' or 'let' to declare bindings that may change.")
.test(src);

TestRun(test, "generator functions")
.addError(2, 1, "Reassignment of 'g', which is a generator function. Use 'var' or 'let' to declare bindings that may change.")
.test([
"function * g () { yield; }",
"g = null;"
], { esversion: 6 });

TestRun(test, "async functions")
.addError(2, 1, "Reassignment of 'a', which is a async function. Use 'var' or 'let' to declare bindings that may change.")
.test([
"async function a () {}",
"a = null;"
], { esversion: 8 });

test.done();
};

0 comments on commit 14384d3

Please sign in to comment.
You can’t perform that action at this time.