示例工程 13-error-handling

13-error-handling/Diagnostics/MissingTry.swift

swift · 0.2 KB

// 故意编译失败:调用可抛错函数必须写 try。
// 复现:swiftc Diagnostics/MissingTry.swift
enum E: Error { case x }
 
func load() throws -> Int {
    throw E.x
}
 
let value = load()
print(value)