mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 21:51:18 +00:00
bab2500197
The latest spec (0.51) says: Attempting to assign to a final variable anywhere except in its declaration or in a constructor header will cause a runtime error to be thrown as discussed below. The assignment will also give rise to a static warning. R=ahe@google.com BUG=7062, 11591 Review URL: https://codereview.chromium.org//22914028 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26519 260f80e4-7a28-3924-810f-c04153c831b5
14 lines
533 B
Dart
14 lines
533 B
Dart
// Copyright (c) 2012, 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.
|
|
|
|
// Test to make sure we catch assignments to final local variables.
|
|
|
|
main() {
|
|
final x = 30;
|
|
x = 0; /// 01: static type warning, runtime error
|
|
x += 1; /// 02: static type warning, runtime error
|
|
++x; /// 03: static type warning, runtime error
|
|
x++; /// 04: static type warning, runtime error
|
|
}
|