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.
This commit is contained in:
Neil Brown 2008-05-20 18:11:05 +00:00
parent 7f387ae6a9
commit 2b3783d845

View File

@ -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 ()