OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 main() { | 5 main() { |
6 var closure; | 6 var closure; |
7 for (var i=0, fn = () => i; i < 3; i++) { | 7 for (var i = 0, fn = () => i; i < 3; i++) { |
8 i += 1; | 8 i += 1; |
9 closure = fn; | 9 closure = fn; |
10 } | 10 } |
11 var x = closure(); | 11 var x = closure(); |
12 if (x != 1) { | 12 if (x != 1) { |
13 throw "Expected 1, but got $x."; | 13 throw "Expected 1, but got $x."; |
14 } | 14 } |
15 } | 15 } |
OLD | NEW |