File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -1063,7 +1063,17 @@ fn monomorphize_expr<B: Backend>(
1063
1063
let else_mono = monomorphize_expr ( ctx, else_, mono_fn_env) ?;
1064
1064
1065
1065
// make sure that the type of then_ and else_ match
1066
- if then_mono. typ != else_mono. typ {
1066
+ let is_match = match ( & then_mono. typ , & else_mono. typ ) {
1067
+ // generics not allowed as they should have been monomorphized
1068
+ ( Some ( then_typ) , Some ( else_typ) ) => then_typ. match_expected ( else_typ, true ) ,
1069
+ _ => Err ( Error :: new (
1070
+ "If-Else Monomorphization" ,
1071
+ ErrorKind :: UnexpectedError ( "Could not resolve type for the `if-else` branch" ) ,
1072
+ expr. span ,
1073
+ ) ) ?,
1074
+ } ;
1075
+
1076
+ if !is_match {
1067
1077
Err ( Error :: new (
1068
1078
"If-Else Monomorphization" ,
1069
1079
ErrorKind :: UnexpectedError (
You can’t perform that action at this time.
0 commit comments