You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the if expr returns a type T then else is expected to produce the same type T but in absence of else branch it return a () type. However, gccrs does not enforce this check.
fnfoo(pred:bool) -> u8{if pred {1}3}fnmain(){}
rustc:
error[E0308]: mismatched types
--><source>:3:9
|
2 | / if pred {
3 || 1
|| ^ expected `()`, found integer4 || }||_____- expected this to be `()`|help: you might have meant to return this value|3 |return 1;| ++++++ +error: aborting due to 1 previous error
If the
if
expr returns a typeT
then else is expected to produce the same typeT
but in absence ofelse
branch it return a()
type. However, gccrs does not enforce this check.rustc:
gccrs: Compiles sucessfully
godbolt: https://godbolt.org/z/xnczfjznT
The text was updated successfully, but these errors were encountered: