LYR-SEM0145
'never' where a value of it would have to exist
The type 'never' stands somewhere other than a return type — a parameter, a binding, a field, an element, an optional — or answers an associated type or a type parameter whose bound is not 'Error', or 'try?' is applied to an expression of type 'never'.
Explanation
never is the type of an expression that does not finish: a function returning never panics, throws or loops forever. No value of it exists, so it stands only as the whole return type of a function, a lambda or a function type. The one exception is a thrown set: an associated type or type parameter bounded by Error may be never, meaning nothing is thrown. A try? over a never expression would be worth ?never, which is always null.
Use the type the value actually has; for an empty array, give its element type.
Wrong
fn main(): void {
let xs: never[] = [];
let _ = xs;
}
Right
fn main(): void {
let xs: int[] = [];
let _ = xs;
}