blob: 4d1597f7b82a3884c4bfe0cc2ee02162b9061f75 [file] [log] [blame]
// Copyright (c) 2022, 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.
/// @assertion The new rules are incorporated into the existing productions for
/// declaring variables like so:
///
/// localVariableDeclaration ::=
/// | metadata initializedVariableDeclaration ';' // Existing.
/// | metadata patternVariableDeclaration ';' // New.
///
/// forLoopParts ::=
/// | // Existing productions...
/// | metadata ( 'final' | 'var' ) outerPattern 'in' expression // New.
/// As with regular for-in loops, it is a compile-time error if the type of
/// expression in a pattern-for-in loop is not assignable to Iterable<dynamic>.
///
/// @description Check that it is a compile-time error if pattern variable
/// declaration is used in static fields
/// @author sgrekhov22@gmail.com
import "patterns_lib.dart";
class Meta {
const Meta();
}
class C {
@Meta()
static final ((a1, b1) && r1) = (1, 2);
// ^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@Meta()
static var [a2, b2] = [1, 2];
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
static final {"key1": a3, "key2": b3} = {"key1": 1, "key2": 2};
// ^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
static var (a4, b4) = (1, 2);
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
static final (:num n1, :n2) = (n1: 3.14, n2: "pi");
// ^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
static var Square(areaAsInt: int a2, sizeAsInt: b2) = Square(1);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
static final Square(:int areaAsInt, :sizeAsInt) = Square(1);
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
main() {
print(C);
}