@@ -1155,15 +1155,27 @@ evalGraphRefTupleExprs mAttrs (TupleExprs fixedMarker tupleExprL) = do
11551155 [] -> pure emptyAttributes
11561156 (headTuple:tailTuples) -> do
11571157 --gather up resolved atom types or throw an error if an attribute cannot be made concrete from the inferred types- this could still fail if the type cannot be inferred (e.g. from [Nothing, Nothing])
1158− let mostResolvedTypes =
1159− foldr (\tup acc ->
1160− fmap (\(tupAttr,accAttr) -> --if the attribute is a constructedatomtype, we can recurse into it to potentially resolve type variables
1161− if isResolvedAttribute accAttr then
1162− accAttr
1163− else
1164− case resolveAttributes accAttr tupAttr of
1165− Left _ -> accAttr
1166− Right val -> val) (zip (V.toList $ tupleAttributes tup) acc)) (V.toList $ tupleAttributes headTuple) tailTuples
1158+ let
1159+ processTupleAttrs (tupAttr, accAttr) =
1160+ --if the attribute is a constructedatomtype, we can recurse into it to potentially resolve type variables
1161+ if isResolvedAttribute accAttr && tupAttr == accAttr then
1162+ pure accAttr
1163+ else
1164+ lift $ except $ resolveAttributes accAttr tupAttr
1165+ mostResolvedTypes <-
1166+ foldM (\acc tup -> do
1167+ let zipped = zip (V.toList $ tupleAttributes tup) acc
1168+ accNames = S.fromList $ map A.attributeName acc
1169+ tupNames = A.attributeNameSet (tupleAttributes tup)
1170+ attrNamesDiff = S.union (S.difference accNames tupNames) (S.difference tupNames accNames)
1171+ unless (null attrNamesDiff) (throwError (AttributeNamesMismatchError attrNamesDiff))
1172+ nextTupleAttrs <- mapM processTupleAttrs zipped
1173+ let diff = A.attributesDifference (A.attributesFromList nextTupleAttrs) (A.attributesFromList acc)
1174+ if diff == A.emptyAttributes then
1175+ pure nextTupleAttrs
1176+ else
1177+ throwError (TupleAttributeTypeMismatchError diff)
1178+ ) (V.toList $ tupleAttributes headTuple) tailTuples
11671179 pure (A.attributesFromList mostResolvedTypes)
11681180 --strategy: if all the tuple expr transaction markers refer to one location, then we can pass the type constructor mapping from that location, otherwise, we cannot assume that the types are the same
11691181 tConsMap <- case singularTransactions tupleExprL of