Skip to content
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

[SR-13845] Segfault: attempt to return unconstrained type from result builder #56243

Closed
stephencelis opened this issue Nov 12, 2020 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@stephencelis
Copy link
Contributor

Previous ID SR-13845
Radar rdar://problem/71330228
Original Reporter @stephencelis
Type Bug
Status Resolved
Resolution Done
Environment

Swift 5.3 via Xcode 12.2 RC

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @stephencelis
Priority Medium

md5: fccd1261912dc319d8850228a7fdeffa

Issue Description:

The following code is invalid because the invocation of build is invalid, but it crashes the compiler:

protocol Thing {
  associatedtype Foo
  associatedtype Bar
}

struct AnyThing<Foo, Bar>: Thing {}

enum Either<A, B> {
  case first(A)
  case second(B)
}

@_functionBuilder
struct ThingBuilder {
  public static func buildEither<A, B>(first value: A) -> Either<A, B>
  where A: Thing, B: Thing {
    .first(value)
  }

  public static func buildEither<A, B>(second value: B) -> Either<A, B>
  where A: Thing, B: Thing {
    .second(value)
  }
}

func build<A>(@ThingBuilder block: () -> A) -> A where A: Thing {
  block()
}

let x = build {
  if Bool.random() {
    AnyThing<Int, Int>()
  } else {
    AnyThing()
  }
}
@typesanitizer
Copy link

@swift-ci create

@xedin
Copy link
Member

xedin commented Nov 13, 2020

Hi @stephencelis, could you please verify that this crash has been fixed in main branch? I have tried with snapshot from 11/09 and it didn't crash.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

3 participants