Skip to content

Commit

Permalink
Fix: no-loop-func crashed (fixes #6130) (#6138)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed May 13, 2016
1 parent d311a62 commit 67916b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-loop-func.js
Expand Up @@ -73,7 +73,7 @@ function getContainingLoopNode(node) {
* @returns {ASTNode} The most outer loop node.
*/
function getTopLoopNode(node, excludedNode) {
var retv = null;
var retv = node;
var border = excludedNode ? excludedNode.range[1] : 0;

while (node && node.range[0] >= border) {
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/rules/no-loop-func.js
Expand Up @@ -107,6 +107,15 @@ ruleTester.run("no-loop-func", rule, {
"result.__default = 6;"
].join("\n"),
parserOptions: { ecmaVersion: 6 }
},
{
code: [
"while (true) {",
" (function() { a; });",
"}",
"let a;"
].join("\n"),
parserOptions: { ecmaVersion: 6 }
}
],
invalid: [
Expand Down

0 comments on commit 67916b9

Please sign in to comment.