Skip to content

Commit 0be33ab

Browse files
committed
check if the expr type is unit for match expressions, too.
1 parent edc16d0 commit 0be33ab

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Compiler/Checking/TailCallChecks.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ type TailCall =
4747
static member YesFromVal (g: TcGlobals) (v: Val) = TailCall.Yes(TailCall.IsVoidRet g v)
4848

4949
static member YesFromExpr (g: TcGlobals) (expr: Expr) =
50+
let yesFromTType (t: TType) =
51+
if isUnitTy g t then
52+
TailCall.Yes TailCallReturnType.MustReturnVoid
53+
else
54+
TailCall.Yes TailCallReturnType.NonVoid
55+
5056
match expr with
5157
| ValUseAtApp(valRef, _) -> TailCall.Yes(TailCall.IsVoidRet g valRef.Deref)
58+
| Expr.Const(constType = constType) -> yesFromTType constType
59+
| Expr.Match(exprType = exprType) -> yesFromTType exprType
5260
| _ -> TailCall.Yes TailCallReturnType.NonVoid
5361

5462
member x.AtExprLambda =

0 commit comments

Comments
 (0)