on master help sign in
The Error structure describes how it should be displayed
1408bc3Evan Czaplicki
src/Type/Occurs.hs+1−1
@@ -21,7 +21,7 @@ occursHelp :: [Type.Variable] -> Type.Variable -> IO Bool
21occursHelp seen var =
21occursHelp seen var =
22 if elem var seen then
22 if elem var seen then
23 do infiniteDescriptor <- UF.descriptor var
23 do infiniteDescriptor <- UF.descriptor var
24− UF.setDescriptor var (infiniteDescriptor { _content = Error })
24+ UF.setDescriptor var (infiniteDescriptor { _content = Error "∞" })
25 return True
25 return True
26
26
27 else
27 else
src/Type/Solve.hs+1−1
@@ -119,7 +119,7 @@ adjustRankContent youngMark visitedMark groupRank content =
119 go = adjustRank youngMark visitedMark groupRank
119 go = adjustRank youngMark visitedMark groupRank
120 in
120 in
121 case content of
121 case content of
122− Error ->
122+ Error _ ->
123 return groupRank
123 return groupRank
124
124
125 Atom _ ->
125 Atom _ ->
src/Type/State.hs+3−3
@@ -339,7 +339,7 @@ makeCopyHelp (Descriptor content rank mark copy) alreadyCopiedMark variable =
339 <*> makeCopy alreadyCopiedMark realType
339 <*> makeCopy alreadyCopiedMark realType
340 )
340 )
341
341
342− Error ->
342+ Error _ ->
343 return ()
343 return ()
344
344
345 return newVar
345 return newVar
@@ -360,7 +360,7 @@ needsCopy content =
360 Alias _ _ _ ->
360 Alias _ _ _ ->
361 True
361 True
362
362
363− Error ->
363+ Error _ ->
364 False
364 False
365
365
366
366
@@ -408,7 +408,7 @@ restoreContent alreadyCopiedMark content =
408 <$> mapM (traverse go) args
408 <$> mapM (traverse go) args
409 <*> go var
409 <*> go var
410
410
411− Error ->
411+ Error _ ->
412 return content
412 return content
413
413
414
414
src/Type/Type.hs+4−4
@@ -62,7 +62,7 @@ data Content
62 | Atom Var.Canonical
62 | Atom Var.Canonical
63 | Var Flex (Maybe Super) (Maybe Text)
63 | Var Flex (Maybe Super) (Maybe Text)
64 | Alias Var.Canonical [(Text,Variable)] Variable
64 | Alias Var.Canonical [(Text,Variable)] Variable
65− | Error
65+ | Error Text
66
66
67
67
68data Flex
68data Flex
@@ -285,8 +285,8 @@ contentToSrcType variable content =
285 srcType <- variableToSrcType realVariable
285 srcType <- variableToSrcType realVariable
286 return (T.Aliased name srcArgs (T.Filled srcType))
286 return (T.Aliased name srcArgs (T.Filled srcType))
287
287
288− Error ->
288+ Error name ->
289− return (T.Var "?")
289+ return (T.Var name)
290
290
291
291
292termToSrcType :: FlatType -> StateT NameState IO T.Canonical
292termToSrcType :: FlatType -> StateT NameState IO T.Canonical
@@ -434,7 +434,7 @@ getVarNames var =
434 Atom _ ->
434 Atom _ ->
435 return ()
435 return ()
436
436
437− Error ->
437+ Error _ ->
438 return ()
438 return ()
439
439
440 Var _ _ Nothing ->
440 Var _ _ Nothing ->
src/Type/Unify.hs+8−8
@@ -34,7 +34,7 @@ unify hint region expected actual =
34 mkError =
34 mkError =
35 do expectedSrcType <- Type.toSrcType expected
35 do expectedSrcType <- Type.toSrcType expected
36 actualSrcType <- Type.toSrcType actual
36 actualSrcType <- Type.toSrcType actual
37− mergeHelp expected actual Error noRank
37+ mergeHelp expected actual (Error "?") noRank
38 let info = Error.MismatchInfo hint expectedSrcType actualSrcType maybeReason
38 let info = Error.MismatchInfo hint expectedSrcType actualSrcType maybeReason
39 return (Error.Mismatch info)
39 return (Error.Mismatch info)
40 in
40 in
@@ -204,7 +204,7 @@ actuallyUnify context@(Context _ _ firstDesc _ secondDesc) =
204 secondContent = _content secondDesc
204 secondContent = _content secondDesc
205 in
205 in
206 case firstContent of
206 case firstContent of
207− Error ->
207+ Error _ ->
208 -- If there was an error, just pretend it is okay. This lets us avoid
208 -- If there was an error, just pretend it is okay. This lets us avoid
209 -- "cascading" errors where one problem manifests as multiple message.
209 -- "cascading" errors where one problem manifests as multiple message.
210 return ()
210 return ()
@@ -235,7 +235,7 @@ actuallyUnify context@(Context _ _ firstDesc _ secondDesc) =
235unifyFlex :: Context -> Content -> Unify ()
235unifyFlex :: Context -> Content -> Unify ()
236unifyFlex context otherContent =
236unifyFlex context otherContent =
237 case otherContent of
237 case otherContent of
238− Error ->
238+ Error _ ->
239 return ()
239 return ()
240
240
241 Var Flex _ _ ->
241 Var Flex _ _ ->
@@ -261,7 +261,7 @@ unifyFlex context otherContent =
261unifyRigid :: Context -> Maybe Super -> Maybe Text -> Content -> Content -> Unify ()
261unifyRigid :: Context -> Maybe Super -> Maybe Text -> Content -> Content -> Unify ()
262unifyRigid context maybeSuper maybeName content otherContent =
262unifyRigid context maybeSuper maybeName content otherContent =
263 case otherContent of
263 case otherContent of
264− Error ->
264+ Error _ ->
265 return ()
265 return ()
266
266
267 Var Flex otherMaybeSuper _ ->
267 Var Flex otherMaybeSuper _ ->
@@ -352,7 +352,7 @@ unifyFlexSuper context super content otherContent =
352 Alias _ _ realVar ->
352 Alias _ _ realVar ->
353 subUnify context (_first context) realVar
353 subUnify context (_first context) realVar
354
354
355− Error ->
355+ Error _ ->
356 return ()
356 return ()
357
357
358
358
@@ -516,7 +516,7 @@ getContent variable =
516unifyAtom :: Context -> Var.Canonical -> Content -> Unify ()
516unifyAtom :: Context -> Var.Canonical -> Content -> Unify ()
517unifyAtom context name otherContent =
517unifyAtom context name otherContent =
518 case otherContent of
518 case otherContent of
519− Error ->
519+ Error _ ->
520 return ()
520 return ()
521
521
522 Var Flex Nothing _ ->
522 Var Flex Nothing _ ->
@@ -562,7 +562,7 @@ isIntFloat name otherName =
562unifyAlias :: Context -> Var.Canonical -> [(Text, Variable)] -> Variable -> Content -> Unify ()
562unifyAlias :: Context -> Var.Canonical -> [(Text, Variable)] -> Variable -> Content -> Unify ()
563unifyAlias context name args realVar otherContent =
563unifyAlias context name args realVar otherContent =
564 case otherContent of
564 case otherContent of
565− Error ->
565+ Error _ ->
566 return ()
566 return ()
567
567
568 Var Flex Nothing _ ->
568 Var Flex Nothing _ ->
@@ -593,7 +593,7 @@ unifyAlias context name args realVar otherContent =
593unifyStructure :: Context -> FlatType -> Content -> Content -> Unify ()
593unifyStructure :: Context -> FlatType -> Content -> Content -> Unify ()
594unifyStructure context term content otherContent =
594unifyStructure context term content otherContent =
595 case otherContent of
595 case otherContent of
596− Error ->
596+ Error _ ->
597 return ()
597 return ()
598
598
599 Var Flex Nothing _ ->
599 Var Flex Nothing _ ->