logoalt Hacker News

kccqzytoday at 1:11 AM1 replyview on HN

No you don’t need coercion. You only need polymorphism. The type of `panic!()` could be an arbitrary U, which unifies just fine with the type T here.

Generally languages with such polymorphism have a never type only because they don’t also support impredicative polymorphism.


Replies

kibwentoday at 2:47 AM

And then once you have `fn foo<T>() -> T`, what do you write in the body that allows it to typecheck?