Skip to content

Instantly share code, notes, and snippets.

@notcome
Created November 16, 2020 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notcome/4d02b132013b9342955d95f4da1a5654 to your computer and use it in GitHub Desktop.
Save notcome/4d02b132013b9342955d95f4da1a5654 to your computer and use it in GitHub Desktop.
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