mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add a test for typed throws and withUnsafe(Mutable)BufferPointer
This commit is contained in:
17
test/stdlib/ArrayTypedThrows.swift
Normal file
17
test/stdlib/ArrayTypedThrows.swift
Normal file
@@ -0,0 +1,17 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
enum MyError: Error {
|
||||
case fail
|
||||
case bad
|
||||
}
|
||||
|
||||
func unsafeBuffers() throws(MyError) {
|
||||
var a = [1, 2, 3]
|
||||
try a.withUnsafeBufferPointer { (buffer) throws(MyError) in
|
||||
throw .bad
|
||||
}
|
||||
|
||||
try a.withUnsafeMutableBufferPointer { (buffer) throws(MyError) in
|
||||
throw .bad
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user