Skip to content

Instantly share code, notes, and snippets.

@notcome
Created November 16, 2020 01:50
Embed
What would you like to do?
protocol DoSomething {
func f()
}
enum Empty {}
extension Empty: DoSomething {
func f() {}
}
struct Container {
var y: Empty
}
extension Container: DoSomething {
func f() {
y.f()
}
}
func g(_ x: Empty) {
print(1)
}
/*
a.swift:22:5: warning: will never be executed
print(1)
^
a.swift:21:20: note: 'x' is uninhabited, so this function body can never be executed
func g(_ x: Empty) {
^
a.swift:17:11: warning: will never be executed
y.f()
^
a.swift:17:9: note: a call to a never-returning function
y.f()
^
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment