typeLinkingExpr db imps su (ArrayAccess arr idx _) = case typeArr of
                                                        [Array tp] -> case typeIdx of
                                                                    [tp'] -> if elem tp' [TypeByte, TypeShort, TypeInt, TypeChar] then [tp] else typeLinkingFailure "Array: index is not an integer"
                                                                    _ -> typeLinkingFailure "Array Index Type typeLinkingFailure"
                                                        _ -> typeLinkingFailure "Array Type cannot be found"
    where
        typeArr = typeLinkingExpr db imps su arr 
        typeIdx = typeLinkingExpr db imps su idx
                
                
-- to check: allow use array of primitive type to cast
typeLinkingExpr db imps su (ArrayAccess arr idx _) = case typeArr of
                                                        [Array tp] -> case typeIdx of
                                                                    [tp'] -> if elem tp' [TypeByte, TypeShort, TypeInt, TypeChar] then [tp] else typeLinkingFailure "Array: index is not an integer"
                                                                    _ -> typeLinkingFailure "Array Index Type typeLinkingFailure"
                                                        _ -> typeLinkingFailure "Array Type cannot be found"
    where
        typeArr = typeLinkingExpr db imps su arr 
        typeIdx = typeLinkingExpr db imps su idx
                
                
-- to check: allow use array of primitive type to cast
typeLinkingExpr db imps su (ArrayAccess arr idx _) = case typeArr of
                                                        [Array tp] -> case typeIdx of
                                                                    [tp'] -> if elem tp' [TypeByte, TypeShort, TypeInt, TypeChar] then [tp] else typeLinkingFailure "Array: index is not an integer"
                                                                    _ -> typeLinkingFailure "Array Index Type typeLinkingFailure"
                                                        _ -> typeLinkingFailure "Array Type cannot be found"
    where
        typeArr = typeLinkingExpr db imps su arr 
        typeIdx = typeLinkingExpr db imps su idx
                
                
-- to check: allow use array of primitive type to cast