diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b239755431..f52bfd66d076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 3.2.5 + +This is a patch release that: + +- Fixes a Dart2js issue with values updated in a loop. (issue [#54494][]) + +[#54494]: https://github.com/dart-lang/sdk/issues/54494 + ## 3.2.4 - 2023-12-21 This is a patch release that: diff --git a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart index 1e292845627f..635fe6446393 100644 --- a/pkg/compiler/lib/src/ssa/value_range_analyzer.dart +++ b/pkg/compiler/lib/src/ssa/value_range_analyzer.dart @@ -530,7 +530,7 @@ class NegateValue extends Value { } return info.newSubtractValue(other, value); } - if (other is InstructionValue) { + if (other is VariableValue) { return info.newSubtractValue(other, value); } return other - value; @@ -548,7 +548,7 @@ class NegateValue extends Value { } return info.newSubtractValue(this, other); } - if (other is InstructionValue) { + if (other is VariableValue) { return info.newSubtractValue(this, other); } if (other is NegateValue) return this + other.value; diff --git a/tests/web/regress/issue/54453_test.dart b/tests/web/regress/issue/54453_test.dart new file mode 100644 index 000000000000..984e2732275e --- /dev/null +++ b/tests/web/regress/issue/54453_test.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2023, 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. + +// Make sure binary operations are correctly handled for range-like values in +// SSA's value range analyzer. + +void main() { + int counter = 0; + for (int i = 0; i < 5; i++) { + counter += counter; + } +}