aboutsummaryrefslogtreecommitdiff
path: root/TypeCheck.hs
diff options
context:
space:
mode:
Diffstat (limited to 'TypeCheck.hs')
-rw-r--r--TypeCheck.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/TypeCheck.hs b/TypeCheck.hs
index 66affa4..922731d 100644
--- a/TypeCheck.hs
+++ b/TypeCheck.hs
@@ -191,15 +191,17 @@ annotateExpr db (ELit (LCall n as) _) = do
when (length as' /= length ats) $
Left $ "Function '" ++ n ++ "' expected " ++ show (length ats) ++
" arguments but got " ++ show (length as')
- forM_ (zip as' ats) $ \(arg, at) -> do
+ forM_ (zip3 as' ats [1 :: Int ..]) $ \(arg, at, num) -> do
when (isNothing (typeof arg)) $
Left "Use of void value in function argument"
if canCoerce (fromJust $ typeof arg) at
then return ()
- else Left $ "Argument of " ++ n ++ " has type " ++ pretty at ++
+ else Left $ "Argument " ++ show num ++ " of " ++ n ++ " has type " ++ pretty at ++
" but value of type " ++ pretty (fromJust $ typeof arg) ++
" was given"
return $ ELit (LCall n as') mrt
+annotateExpr _ (ELit lit@(LStr s) _) =
+ return $ ELit lit (Just $ TArr TChar (Just $ fromIntegral $ length s))
annotateExpr db (ESubscript arr sub _) = do
arr' <- annotateExpr db arr
sub' <- annotateExpr db sub