| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Dart test program for testing the prohibited use of a variable before it has | 4 // Dart test program for testing the prohibited use of a variable before it has |
| 5 // been declared, which is not trivial to detect in the context of a variable | 5 // been declared, which is not trivial to detect in the context of a variable |
| 6 // declaration shadowing another one. | 6 // declaration shadowing another one. |
| 7 | 7 |
| 8 class ScopeNegativeTest { | 8 class ScopeNegativeTest { |
| 9 static testMain() { | 9 static testMain() { |
| 10 var a = 1; | 10 var a = 1; |
| 11 { | 11 { |
| 12 var b = 2; | 12 var b = 2; |
| 13 var c = a; // Use of 'a' prior to its shadow declaration below. | 13 var c = a; // Use of 'a' prior to its shadow declaration below. |
| 14 var d = b + c; | 14 var d = b + c; |
| 15 var a = 5; // Shadow declaration of 'a'. | 15 var a = 5; // Shadow declaration of 'a'. |
| 16 return d + a; | 16 return d + a; |
| 17 } | 17 } |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 | 21 |
| 22 main() { | 22 main() { |
| 23 ScopeNegativeTest.testMain(); | 23 ScopeNegativeTest.testMain(); |
| 24 } | 24 } |
| OLD | NEW |