mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:02:31 +00:00
4b9c2356e9
A HParameterValue can be an SSA value or a mutable local variable accessed via HLocalFet/HLocalSet. The latter happens in code that is not completely SSA-converted (due to exception control flow). The main bug is that the check on a mutable-variable-mode HParameterValue should have been on a HLocalGet of the value, and not the HParameterValue itself. This means that a reference to the HParameterValue cannot be replaced with a strengthening check, as that breaks the invariant that HLocalGet/Set refer to variables. There was code in types_propagation that tried to work around this broken invariant. The bug (issue 42189) required - An elided instance method parameter - try(-catch)(-finally) to avoid complete SSA-conversion - -O0 to avoid optimizing away the check early with inferred types The first attempt at a fix was to not check the elided parameter at all since the default value is statically checked. This is still worthwhile. Bug: 42189 Change-Id: Idd5e2b1485eba4950a36d1e4ff57ebe35e4c98a0 Fixed: 42189 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150171 Reviewed-by: Sigmund Cherem <sigmund@google.com> Commit-Queue: Stephen Adams <sra@google.com>
40 lines
876 B
Dart
40 lines
876 B
Dart
// Copyright (c) 2020, 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.
|
|
//
|
|
// dart2jsOptions=-O0
|
|
|
|
// @dart = 2.7
|
|
|
|
// Regression test for issue 42891. The root cause was a malformed SSA due to
|
|
// generating a dynamic entry point argument test for an elided parameter
|
|
// directly on the HLocalValue , which should only be an operand to HLocalGet
|
|
// and HLocalSet.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class CCC {
|
|
void foo([num x = 123]) {
|
|
try {
|
|
Expect.equals(123, x);
|
|
x = 0;
|
|
} finally {
|
|
Expect.equals(0, x);
|
|
}
|
|
}
|
|
|
|
void bar([num x = 456]) {
|
|
try {
|
|
Expect.equals(123, x);
|
|
x = 0;
|
|
} finally {
|
|
Expect.equals(0, x);
|
|
}
|
|
}
|
|
}
|
|
|
|
void main() {
|
|
CCC().foo();
|
|
CCC().bar(123);
|
|
}
|