fix null not accepted for object method parameter
This commit is contained in:
parent
361643a85a
commit
8a6dca4e36
@ -171,7 +171,7 @@ typeCheckStatementExpression (MethodCall expr methodName args) symtab classes =
|
|||||||
let args' = map (\arg -> typeCheckExpression arg symtab classes) args
|
let args' = map (\arg -> typeCheckExpression arg symtab classes) args
|
||||||
expectedTypes = [dataType | ParameterDeclaration dataType _ <- params]
|
expectedTypes = [dataType | ParameterDeclaration dataType _ <- params]
|
||||||
argTypes = map getTypeFromExpr args'
|
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
|
mismatches = filter (not . fst3) typeMatches
|
||||||
where fst3 (a, _, _) = a
|
where fst3 (a, _, _) = a
|
||||||
in
|
in
|
||||||
@ -186,6 +186,7 @@ typeCheckStatementExpression (MethodCall expr methodName args) symtab classes =
|
|||||||
Nothing -> error $ "Class for object type '" ++ objType ++ "' not found."
|
Nothing -> error $ "Class for object type '" ++ objType ++ "' not found."
|
||||||
_ -> error "Invalid object type for method call. Object must have a class type."
|
_ -> error "Invalid object type for method call. Object must have a class type."
|
||||||
|
|
||||||
|
|
||||||
typeCheckStatementExpression (PostIncrement expr) symtab classes =
|
typeCheckStatementExpression (PostIncrement expr) symtab classes =
|
||||||
let expr' = typeCheckExpression expr symtab classes
|
let expr' = typeCheckExpression expr symtab classes
|
||||||
type' = getTypeFromExpr expr'
|
type' = getTypeFromExpr expr'
|
||||||
|
Loading…
Reference in New Issue
Block a user