// 故意编译失败:onKeyPress 的闭包要返回 KeyPress.Result,不是 Bool。 // 复现:swiftc -typecheck Diagnostics/KeyPressReturnsBool.swift import SwiftUI struct Bad: View { var body: some View { Text("x").onKeyPress(.return) { true } } }