While writing some code in my project the Swift compiler suddenly started crashing. A clean compile showed me the "Please submit a bug report" message pointing to an (incorrect) switch expression, so here I am filing the bug report. :)
Reproduction
class InputRecorder {
private var eventMonitor: Task<Void, Never>?
// ...
func setup() async throws {
eventMonitor = Task { [captureMode] in
let cgEventStream = switch captureMode {
case .mouseEvents:
CGEvent.combinedMonitorForEvents(matching: mouseEventsTypeMask)
case .keyboardEvents, .mouseAndKeyboardEvents:
let eventTypes = captureMode.eventTypes.union(tapDisabledTypes)
let eventMask = CGEventMask(types: eventTypes)
return CGEvent.eventTapForEvents(matching: eventMask) // This return is wrong
}
// ...
}
}
// ...
}
Description
While writing some code in my project the Swift compiler suddenly started crashing. A clean compile showed me the "Please submit a bug report" message pointing to an (incorrect) switch expression, so here I am filing the bug report. :)
Reproduction
Stack dump
Expected behavior
Error reporting that the return statement in the last case isn't allowed, since the switch is used as an expression.
Environment
❯ swiftc --version swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-macosx14.0
Also happens in Xcode 15.4 (15F31d).
Additional information
No response