From 2b3783d84554ff8d74887e9242a1436f76eba8b9 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 20 May 2008 18:11:05 +0000 Subject: [PATCH] Fixed the handling of types for function returns Function returns are done in Rain by assigning to the function name, so we need a bit of extra code when checking assignments to see if the LHS is a function name. --- frontends/RainTypes.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontends/RainTypes.hs b/frontends/RainTypes.hs index 34aa1de..ff57472 100644 --- a/frontends/RainTypes.hs +++ b/frontends/RainTypes.hs @@ -214,7 +214,15 @@ markAssignmentTypes = checkDepthM checkAssignment = do am <- abbrevModeOfVariable v when (am == A.ValAbbrev) $ diePC m $ formatCode "Cannot assign to a constant variable: %" v - markUnify v e + -- Assignments also includes assignments to function names, + -- so we need a little extra logic: + case v of + A.Variable _ n -> + do st <- specTypeOfName n + case st of + A.Function _ _ [t] _ _ -> markUnify t e + _ -> markUnify v e + _ -> markUnify v e checkAssignment (A.Assign m _ _) = dieInternal (Just m,"Rain checker found occam-style assignment") checkAssignment st = return ()