blob: d8e3f2704a58d9794d59f85c254f5b5d7b6b77dd [file] [log] [blame]
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
// Regression test for dartbug.com/32597: incorrect type was assigned to phi
// in strong mode.
// VMOptions=--optimization_counter_threshold=10 --no-background-compilation
import "package:expect/expect.dart";
class Token {
Token next;
}
class StringToken extends Token {}
class ErrorToken extends Token {}
bool failed = false;
void foo(Token tokens, {bool x: false}) {
dynamic v;
{
Token current = tokens;
while (current is ErrorToken) {
failed = true;
current = null;
}
v = current;
}
if (x) {
ErrorToken second = v;
print(second);
}
}
void main() {
Token token = new StringToken();
token.next = token;
for (int i = 0; i < 100; i++) {
foo(token);
}
print(failed ? 'failure' : 'success');
Expect.isFalse(failed);
}