mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:01:19 +00:00
ea03ea355c
The current behavior is inconsistent across the backends so locking this down in weak mode feels like a subtle breaking change. The VM currently tries calling .iterable and throws a NoSuchMethodError. DDC throws a TypeError. Change-Id: Ib121a91f045a4f190be77dc57b5c216d818e0301 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144683 Reviewed-by: Bob Nystrom <rnystrom@google.com> Commit-Queue: Nicholas Shahan <nshahan@google.com>
24 lines
972 B
Dart
24 lines
972 B
Dart
// Copyright (c) 2019, 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.
|
|
|
|
// Requirements=nnbd-weak
|
|
import 'package:expect/expect.dart';
|
|
|
|
void main() {
|
|
// Null condition expression.
|
|
dynamic nullBool = null;
|
|
Expect.throwsAssertionError(() => <int>[for (; nullBool;) 1]);
|
|
Expect.throwsAssertionError(() => <int, int>{for (; nullBool;) 1: 1});
|
|
Expect.throwsAssertionError(() => <int>{for (; nullBool;) 1});
|
|
|
|
// Null iterable.
|
|
dynamic nullIterable = null;
|
|
// The current behavior is inconsistent across the backends. The VM currently
|
|
// tries calling .iterable and throws a NoSuchMethodError. DDC throws a
|
|
// TypeError.
|
|
Expect.throws(() => <int>[for (var i in nullIterable) 1]);
|
|
Expect.throws(() => <int, int>{for (var i in nullIterable) 1: 1});
|
|
Expect.throws(() => <int>{for (var i in nullIterable) 1});
|
|
}
|