mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
82b78916fd
Change-Id: If31c487e3ebe2c1ae847aff7c8994580b8b6f2f6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/309660 Reviewed-by: Alexander Thomas <athom@google.com> Commit-Queue: Alexander Thomas <athom@google.com>
30 lines
1 KiB
Dart
30 lines
1 KiB
Dart
// Copyright (c) 2023, 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.
|
|
|
|
// Test that the proper errors are generated if a declared variable appears
|
|
// inside a pattern assignment.
|
|
|
|
void usingFinal() {
|
|
var [final y] = [0];
|
|
// ^^^^^
|
|
// [analyzer] SYNTACTIC_ERROR.VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT
|
|
// [cfe] Variable patterns in declaration context can't specify 'var' or 'final' keyword.
|
|
}
|
|
|
|
void usingFinalAndType() {
|
|
var [final int y] = [0, 1];
|
|
// ^^^^^
|
|
// [analyzer] SYNTACTIC_ERROR.VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT
|
|
// [cfe] Variable patterns in declaration context can't specify 'var' or 'final' keyword.
|
|
}
|
|
|
|
void usingVar() {
|
|
var [var y] = [0, 1];
|
|
// ^^^
|
|
// [analyzer] SYNTACTIC_ERROR.VARIABLE_PATTERN_KEYWORD_IN_DECLARATION_CONTEXT
|
|
// [cfe] Variable patterns in declaration context can't specify 'var' or 'final' keyword.
|
|
}
|
|
|
|
main() {}
|