From 8a6dca4e3610ee4575d5c3945fca88d809aab1c5 Mon Sep 17 00:00:00 2001 From: MisterChaos96 Date: Thu, 20 Jun 2024 08:38:56 +0200 Subject: [PATCH] fix null not accepted for object method parameter --- src/Typecheck.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Typecheck.hs b/src/Typecheck.hs index 0be409f..7564de7 100644 --- a/src/Typecheck.hs +++ b/src/Typecheck.hs @@ -171,7 +171,7 @@ typeCheckStatementExpression (MethodCall expr methodName args) symtab classes = let args' = map (\arg -> typeCheckExpression arg symtab classes) args expectedTypes = [dataType | ParameterDeclaration dataType _ <- params] argTypes = map getTypeFromExpr args' - typeMatches = zipWith (\expType argType -> (expType == argType, expType, argType)) expectedTypes argTypes + typeMatches = zipWith (\expType argType -> (expType == argType || (argType == "null" && isObjectType expType), expType, argType)) expectedTypes argTypes mismatches = filter (not . fst3) typeMatches where fst3 (a, _, _) = a in @@ -186,6 +186,7 @@ typeCheckStatementExpression (MethodCall expr methodName args) symtab classes = Nothing -> error $ "Class for object type '" ++ objType ++ "' not found." _ -> error "Invalid object type for method call. Object must have a class type." + typeCheckStatementExpression (PostIncrement expr) symtab classes = let expr' = typeCheckExpression expr symtab classes type' = getTypeFromExpr expr'