OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // Regression test for issue 22822. The assignment in the finally block |
| 6 // used to crash because it was executed at context level 1 instead of |
| 7 // context level 2. |
| 8 |
| 9 import 'package:expect/expect.dart'; |
| 10 |
| 11 test(b) { |
| 12 try { |
| 13 for (int i = 0; i < 10; i++) { |
| 14 // Closurizing i and b, thus the return statement |
| 15 // executes at context level 2, and the code in |
| 16 // the finally block runs at context level 1. |
| 17 return () => i + b; |
| 18 } |
| 19 } finally { |
| 20 b = 10; |
| 21 } |
| 22 } |
| 23 |
| 24 main() { |
| 25 var c = test(0); |
| 26 Expect.equals(10, c()); |
| 27 } |
OLD | NEW |