Skip to content

Fixes #1375. Add test for final variable in a for-in loop #1378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Language/Statements/For/For_in/execution_t07.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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 Let D be derived from < finalConstVarOrType >?. A for statement
/// of the form for (D id in e) S is then treated as the following code, where
/// id1 and id2 are fresh identifiers:
/// T id1 = e;
/// var id2 = id1.iterator;
/// while (id2.moveNext()) {
/// D id = id2.current;
/// { S }
/// }
/// If the static type of e is a top type then T is Iterable<dynamic>, otherwise
/// T is the static type of e. It is a compile-time error if T is not assignable
/// to Iterable<dynamic>.
///
/// @description Checks that it is a compile-time error if D is empty and id is
/// a final variable
/// @author [email protected]
/// @issue 49495

main() {
final i;
for (i in [1, 2, 3]) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
}