Fix completion record for labeled statement (#13084)

`{labelAlthoughIMeantItToBeAKey: value}` strikes again :)
This commit is contained in:
Anna Henningsen 2021-04-20 17:08:46 +02:00 committed by GitHub
parent 691c46846f
commit b971e00eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 2 deletions

View File

@ -21,6 +21,9 @@ const x = (n) => do {
}
{ break; "l" }
case 7:
{ a: "m" }
break;
case 8:
}
}
@ -31,4 +34,5 @@ expect(x(3)).toBeUndefined()
expect(x(4)).toBe("g")
expect(x(5)).toBe("j")
expect(x(6)).toBe("k")
expect(x(7)).toBeUndefined()
expect(x(7)).toBe("m")
expect(x(8)).toBeUndefined()

View File

@ -21,5 +21,8 @@ const x = (n) => do {
}
{ break; "l" }
case 7:
{ a: "m" }
break;
case 8:
}
}

View File

@ -62,5 +62,10 @@ const x = n => function () {
}
case 7:
{
a: return "m";
}
case 8:
}
}();

View File

@ -210,7 +210,12 @@ function _getCompletionRecords(
if (path.isIfStatement()) {
records = addCompletionRecords(path.get("consequent"), records, context);
records = addCompletionRecords(path.get("alternate"), records, context);
} else if (path.isDoExpression() || path.isFor() || path.isWhile()) {
} else if (
path.isDoExpression() ||
path.isFor() ||
path.isWhile() ||
path.isLabeledStatement()
) {
// @ts-expect-error(flow->ts): todo
records = addCompletionRecords(path.get("body"), records, context);
} else if (path.isProgram() || path.isBlockStatement()) {