Files
sdk/tests/language/closure_self_reference_test.dart
T
floitsch@google.com a8c4502e23 Fix crash when a closure self-referenced in a try.
In host-checked mode dart2js would crash when a nested function would reference itself again inside a try/catch.

R=johnniwinther@google.com

Review URL: https://codereview.chromium.org//308283003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37488 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-19 12:12:46 +00:00

24 lines
594 B
Dart

// Copyright (c) 2014, 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.
import 'package:expect/expect.dart';
// Tests a self-reference of a closure inside a try/catch.
// Dart2js must not try to box the closure-reference.
main() {
var counter = 0;
inner(value) {
if (value == 0) return 0;
try {
return inner(value - 1);
} finally {
counter++;
}
}
Expect.equals(0, inner(499));
Expect.equals(499, counter);
}