mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* [IRGen] Properly handle empty payloads in getEnumTagMultipayload rdar://97914498 The generated code assumed that payloads would always be at least 1 byte long, ignoring the possibility of empty payloads, causing runtime crashes when using empty payloads in multi payload enums. * Fix test * Remove unnecessary basic block
33 lines
763 B
Swift
33 lines
763 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swiftc_driver -Xfrontend -disable-availability-checking -O -Xllvm -sil-opt-pass-count=0 -Xfrontend -disable-llvm-optzns %s -o %t/out
|
|
// RUN: %target-codesign %t/out
|
|
// RUN: %target-run %t/out
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: foundation
|
|
|
|
// This is a regression test that ensures that empty payloads in multi
|
|
// payload enums are properly handled.
|
|
|
|
import Foundation
|
|
|
|
@inline(never)
|
|
func crash() {
|
|
let testURL = URL(string: "https://www.google.com")!
|
|
let r = Resource<()>(url: testURL, method: .get)
|
|
print(r.url)
|
|
}
|
|
|
|
enum HTTPMethod<Payload> {
|
|
case get
|
|
case post(Payload)
|
|
case patch(Payload)
|
|
}
|
|
|
|
struct Resource<Payload> {
|
|
let url: URL
|
|
let method: HTTPMethod<Payload>
|
|
}
|
|
|
|
crash()
|