JS: fix compiler crash when optimizing JS AST with empty do..while statement. See KT-15513
This commit is contained in:
Vendored
-3
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
OUTER@while (true) {
|
||||
var x = ""
|
||||
|
||||
@@ -62,7 +62,7 @@ internal class DoWhileGuardElimination(private val root: JsStatement) {
|
||||
val body = x.body
|
||||
val guard = when (body) {
|
||||
is JsBlock -> {
|
||||
val firstStatement = body.statements.first()
|
||||
val firstStatement = body.statements.firstOrNull()
|
||||
if (firstStatement is JsLabel && body.statements.size == 1) {
|
||||
firstStatement
|
||||
}
|
||||
|
||||
@@ -24,4 +24,6 @@ class DoWhileGuardEliminationTest : BasicOptimizerTest("do-while-guard-eliminati
|
||||
@Test fun innerContinue() = box()
|
||||
|
||||
@Test fun innerBreakInLoopWithoutLabel() = box()
|
||||
|
||||
@Test fun emptyDoWhile() = box()
|
||||
}
|
||||
+1
-7
@@ -5033,13 +5033,7 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
@TestMetadata("breakFromOuter.kt")
|
||||
public void testBreakFromOuter() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/controlStructures/breakContinueInExpressions/breakFromOuter.kt");
|
||||
try {
|
||||
doTest(fileName);
|
||||
}
|
||||
catch (Throwable ignore) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("breakInDoWhile.kt")
|
||||
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
function box() {
|
||||
do {
|
||||
} while (false);
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
function box() {
|
||||
do {
|
||||
} while (false);
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user