<commit_before>// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input always
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: OS=macosx
// REQUIRES: CPU=x86_64

import Dispatch

struct Boom: Error {}
struct IgnoredBoom: Error {}

func echo(_ i: Int) async -> Int { i }
func boom() async throws -> Int { throw Boom() }

func test_taskGroup_throws_rethrows() async {
  do {
    let got = try await Task.withGroup(resultType: Int.self) { (group) async throws -> Int in
      await group.add { await echo(1) }
      await group.add { await echo(2) }
      await group.add { try await boom() }

      do {
        while let r = try await group.next() {
          print("next: \(r)")
        }
      } catch {
        print("error caught and rethrown in group: \(error)")
        throw error
      }

      fatalError("should have thrown")
    }

      print("got: \(got)")
      fatalError("Expected error to be thrown, but got: \(got)")
  } catch {<commit_msg>[Test] Temporarily disable Runtime/async_taskgroup_throw_rethrow.swift<commit_after>// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-concurrency) | %FileCheck %s --dump-input always
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: OS=macosx
// REQUIRES: CPU=x86_64

// Remove with rdar://problem/73154198
// UNSUPPORTED: asan

import Dispatch

struct Boom: Error {}
struct IgnoredBoom: Error {}

func echo(_ i: Int) async -> Int { i }
func boom() async throws -> Int { throw Boom() }

func test_taskGroup_throws_rethrows() async {
  do {
    let got = try await Task.withGroup(resultType: Int.self) { (group) async throws -> Int in
      await group.add { await echo(1) }
      await group.add { await echo(2) }
      await group.add { try await boom() }

      do {
        while let r = try await group.next() {
          print("next: \(r)")
        }
      } catch {
        print("error caught and rethrown in group: \(error)")
        throw error
      }

      fatalError("should have thrown")
    }

      print("got: \(got)")
      fatalError("Expected error to be thrown, but got: \(got)")
  } catch {
{'fraction_non_alphanumeric': 0.13225806451612904, 'fraction_numerical': 0.009216589861751152, 'mean_word_length': 2.7366609294320137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5830008', 'n_tokens_mistral': 720, 'n_tokens_neox': 699, 'n_words': 206}