however, if i call it with Link == Never, i get the “warning: will never be executed” warning:
warning: will never be executed
return .code(Self.highlight(signature) { _ in fatalError("unreachable") })
^
note: '_' is of type 'Never' which cannot be constructed because it is an
enum with no cases
return .code(Self.highlight(signature) { _ in fatalError("unreachable") })
I ran across a similar issue a few weeks ago when I tried to switch over a multi-thousand case enum. The switch was technically exhaustive, but the compiler told me it didn't want to do the checking and recommended I short-circuit by adding a default. It compiled once I added the default, however with a warning similar to will never be executed .
Ugh, I am able to reproduce it with both my minimal example and yours; the warning is just suppressed in Swift Playgrounds (which I find handy for these little snippets).
It's not exactly a diagnostics bug, as the fatalError call is indeed unreachable. Rather, there seems to be some sort of type inference bug, as a sufficient workaround is actually to annotate the closure argument type, leaving the body empty:
foo(first: [0], second: [] as [Never]) { (_: Never) -> Int in }
Put another way, it's the error you encounter with an empty closure that's the bug and not the warning, and that is indeed worthy of a report.