dart-sdk/tests/language_2/labeled_variable_declaration_test.dart
Jens Johansen 993f7260c1 Labeled variable declarations shouldn't introduce a new scope
Before, e.g.
```
main() {
  L: var x, y;
  x = 42;
  y = x;
}
```

would produce something like
```
static method main() → dynamic {
  {
    dynamic x;
    dynamic y;
  }
  x = 42;
  y = x;
}
```

i.e., the variable declaration was in another scope, and their usage
isn't legal.

This CL fixes that by either
a) (the normal case) not wrapping it --- the label is not used anyway.
b) (the case that cannot happen) put a label on the first part so the
   output would be something like
```
  L: dynamic x;
  dynamic y;
  x = 42;
  y = x;
```

Fixes #34943.

Change-Id: I24132665dab53fb8fb024f73dd11e0d1f1945812
Reviewed-on: https://dart-review.googlesource.com/c/82063
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
2018-11-02 10:20:42 +00:00

11 lines
264 B
Dart

// Copyright (c) 2018, 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.
main() {
L:
var x, y;
x = 42;
y = x;
}