blob: d66589ef795d4aa0aa396511950be39c7e03d73c [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.
import 'dart:async';
late StreamSubscription sub;
main() async {
sub = foo().listen((_) => throw 'unexpected item');
}
Stream<int> foo() async* {
// While the generator (i.e. this function) runs, we cancel the consumer and
// try to yield more.
sub.cancel();
yield* Stream.fromIterable([1, 2, 3]);
throw 'should not run';
}