| Index: compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
|
| diff --git a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
|
| index da4e27e491273ac5925bf9d330092090868500dd..589eb473666452ca6dc190cc3e0c09b4bbab3231 100644
|
| --- a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
|
| +++ b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java
|
| @@ -670,6 +670,29 @@ public class NegativeResolverTest extends CompilerTestCase {
|
| errEx(ResolverErrorCode.DUPLICATE_LOCAL_VARIABLE_WARNING, 6, 11, 1));
|
| }
|
|
|
| + /**
|
| + * Here we have two local variables: one in "main" and one in the scope on "block". However
|
| + * variables are declared in lexical scopes, i.e. in "block", so using it before declaration is
|
| + * error.
|
| + * <p>
|
| + * http://code.google.com/p/dart/issues/detail?id=2382
|
| + */
|
| + public void test_useVariable_beforeDeclaration_inLexicalScope() throws Exception {
|
| + checkSourceErrors(
|
| + makeCode(
|
| + "// filler filler filler filler filler filler filler filler filler filler",
|
| + "main() {",
|
| + " var x;",
|
| + " {",
|
| + " x = 1;",
|
| + " var x;",
|
| + " }",
|
| + "}",
|
| + ""),
|
| + errEx(ResolverErrorCode.USING_LOCAL_VARIABLE_BEFORE_DECLARATION, 5, 5, 1),
|
| + errEx(ResolverErrorCode.DUPLICATE_LOCAL_VARIABLE_WARNING, 6, 9, 1));
|
| + }
|
| +
|
| public void test_nameShadow_field_variable() {
|
| checkSourceErrors(
|
| makeCode(
|
|
|