Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java

Issue 10581024: Issue 2382. Using a variable in a scope before its declared that shadows another variable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 package com.google.dart.compiler.resolver; 4 package com.google.dart.compiler.resolver;
5 5
6 import static com.google.dart.compiler.common.ErrorExpectation.assertErrors; 6 import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
7 import static com.google.dart.compiler.common.ErrorExpectation.errEx; 7 import static com.google.dart.compiler.common.ErrorExpectation.errEx;
8 8
9 import com.google.dart.compiler.CompilerTestCase; 9 import com.google.dart.compiler.CompilerTestCase;
10 import com.google.dart.compiler.DartCompilationError; 10 import com.google.dart.compiler.DartCompilationError;
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 " bar() {", 663 " bar() {",
664 " {", 664 " {",
665 " var bb;", 665 " var bb;",
666 " }", 666 " }",
667 " var bb;", 667 " var bb;",
668 " }", 668 " }",
669 "}"), 669 "}"),
670 errEx(ResolverErrorCode.DUPLICATE_LOCAL_VARIABLE_WARNING, 6, 11, 1)); 670 errEx(ResolverErrorCode.DUPLICATE_LOCAL_VARIABLE_WARNING, 6, 11, 1));
671 } 671 }
672 672
673 /**
674 * Here we have two local variables: one in "main" and one in the scope on "bl ock". However
675 * variables are declared in lexical scopes, i.e. in "block", so using it befo re declaration is
676 * error.
677 * <p>
678 * http://code.google.com/p/dart/issues/detail?id=2382
679 */
680 public void test_useVariable_beforeDeclaration_inLexicalScope() throws Excepti on {
681 checkSourceErrors(
682 makeCode(
683 "// filler filler filler filler filler filler filler filler filler f iller",
684 "main() {",
685 " var x;",
686 " {",
687 " x = 1;",
688 " var x;",
689 " }",
690 "}",
691 ""),
692 errEx(ResolverErrorCode.USING_LOCAL_VARIABLE_BEFORE_DECLARATION, 5, 5, 1 ),
693 errEx(ResolverErrorCode.DUPLICATE_LOCAL_VARIABLE_WARNING, 6, 9, 1));
694 }
695
673 public void test_nameShadow_field_variable() { 696 public void test_nameShadow_field_variable() {
674 checkSourceErrors( 697 checkSourceErrors(
675 makeCode( 698 makeCode(
676 "// filler filler filler filler filler filler filler filler filler f iller", 699 "// filler filler filler filler filler filler filler filler filler f iller",
677 "class A {", 700 "class A {",
678 " var a;", 701 " var a;",
679 " foo() {", 702 " foo() {",
680 " var a;", 703 " var a;",
681 " var bb;", 704 " var bb;",
682 " }", 705 " }",
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 checkSourceErrors( 1305 checkSourceErrors(
1283 makeCode( 1306 makeCode(
1284 "class A {", 1307 "class A {",
1285 "}", 1308 "}",
1286 "method() {", 1309 "method() {",
1287 " A.method();", // error 1310 " A.method();", // error
1288 "}"), 1311 "}"),
1289 errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD_IN_CLASS, 4, 5, 6)); 1312 errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD_IN_CLASS, 4, 5, 6));
1290 } 1313 }
1291 } 1314 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698