on master help sign in
The Error structure describes how it should be displayed

This way we can decide whether to show ? or ∞ depending on how we arrived at the error.

commit1408bc357c6eb670c272437d87f233180a7bdf28 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 1 Jun 2017, 23:45 (9 years ago) parent65aa02a
5 files changed+17−17
src/Type/Occurs.hs+1−1 src/Type/Solve.hs+1−1 src/Type/State.hs+3−3 src/Type/Type.hs+4−4 src/Type/Unify.hs+8−8
src/Type/Occurs.hs+1−1
@@ -21,7 +21,7 @@ occursHelp :: [Type.Variable] -> Type.Variable -> IO Bool
2121occursHelp seen var =
2222 if elem var seen then
2323 do infiniteDescriptor <- UF.descriptor var
24− UF.setDescriptor var (infiniteDescriptor { _content = Error })
24+ UF.setDescriptor var (infiniteDescriptor { _content = Error "∞" })
2525 return True
2626
2727 else
src/Type/Solve.hs+1−1
@@ -119,7 +119,7 @@ adjustRankContent youngMark visitedMark groupRank content =
119119 go = adjustRank youngMark visitedMark groupRank
120120 in
121121 case content of
122− Error ->
122+ Error _ ->
123123 return groupRank
124124
125125 Atom _ ->
src/Type/State.hs+3−3
@@ -339,7 +339,7 @@ makeCopyHelp (Descriptor content rank mark copy) alreadyCopiedMark variable =
339339 <*> makeCopy alreadyCopiedMark realType
340340 )
341341
342− Error ->
342+ Error _ ->
343343 return ()
344344
345345 return newVar
@@ -360,7 +360,7 @@ needsCopy content =
360360 Alias _ _ _ ->
361361 True
362362
363− Error ->
363+ Error _ ->
364364 False
365365
366366
@@ -408,7 +408,7 @@ restoreContent alreadyCopiedMark content =
408408 <$> mapM (traverse go) args
409409 <*> go var
410410
411− Error ->
411+ Error _ ->
412412 return content
413413
414414
src/Type/Type.hs+4−4
@@ -62,7 +62,7 @@ data Content
6262 | Atom Var.Canonical
6363 | Var Flex (Maybe Super) (Maybe Text)
6464 | Alias Var.Canonical [(Text,Variable)] Variable
65− | Error
65+ | Error Text
6666
6767
6868data Flex
@@ -285,8 +285,8 @@ contentToSrcType variable content =
285285 srcType <- variableToSrcType realVariable
286286 return (T.Aliased name srcArgs (T.Filled srcType))
287287
288− Error ->
289− return (T.Var "?")
288+ Error name ->
289+ return (T.Var name)
290290
291291
292292termToSrcType :: FlatType -> StateT NameState IO T.Canonical
@@ -434,7 +434,7 @@ getVarNames var =
434434 Atom _ ->
435435 return ()
436436
437− Error ->
437+ Error _ ->
438438 return ()
439439
440440 Var _ _ Nothing ->
src/Type/Unify.hs+8−8
@@ -34,7 +34,7 @@ unify hint region expected actual =
3434 mkError =
3535 do expectedSrcType <- Type.toSrcType expected
3636 actualSrcType <- Type.toSrcType actual
37− mergeHelp expected actual Error noRank
37+ mergeHelp expected actual (Error "?") noRank
3838 let info = Error.MismatchInfo hint expectedSrcType actualSrcType maybeReason
3939 return (Error.Mismatch info)
4040 in
@@ -204,7 +204,7 @@ actuallyUnify context@(Context _ _ firstDesc _ secondDesc) =
204204 secondContent = _content secondDesc
205205 in
206206 case firstContent of
207− Error ->
207+ Error _ ->
208208 -- If there was an error, just pretend it is okay. This lets us avoid
209209 -- "cascading" errors where one problem manifests as multiple message.
210210 return ()
@@ -235,7 +235,7 @@ actuallyUnify context@(Context _ _ firstDesc _ secondDesc) =
235235unifyFlex :: Context -> Content -> Unify ()
236236unifyFlex context otherContent =
237237 case otherContent of
238− Error ->
238+ Error _ ->
239239 return ()
240240
241241 Var Flex _ _ ->
@@ -261,7 +261,7 @@ unifyFlex context otherContent =
261261unifyRigid :: Context -> Maybe Super -> Maybe Text -> Content -> Content -> Unify ()
262262unifyRigid context maybeSuper maybeName content otherContent =
263263 case otherContent of
264− Error ->
264+ Error _ ->
265265 return ()
266266
267267 Var Flex otherMaybeSuper _ ->
@@ -352,7 +352,7 @@ unifyFlexSuper context super content otherContent =
352352 Alias _ _ realVar ->
353353 subUnify context (_first context) realVar
354354
355− Error ->
355+ Error _ ->
356356 return ()
357357
358358
@@ -516,7 +516,7 @@ getContent variable =
516516unifyAtom :: Context -> Var.Canonical -> Content -> Unify ()
517517unifyAtom context name otherContent =
518518 case otherContent of
519− Error ->
519+ Error _ ->
520520 return ()
521521
522522 Var Flex Nothing _ ->
@@ -562,7 +562,7 @@ isIntFloat name otherName =
562562unifyAlias :: Context -> Var.Canonical -> [(Text, Variable)] -> Variable -> Content -> Unify ()
563563unifyAlias context name args realVar otherContent =
564564 case otherContent of
565− Error ->
565+ Error _ ->
566566 return ()
567567
568568 Var Flex Nothing _ ->
@@ -593,7 +593,7 @@ unifyAlias context name args realVar otherContent =
593593unifyStructure :: Context -> FlatType -> Content -> Content -> Unify ()
594594unifyStructure context term content otherContent =
595595 case otherContent of
596− Error ->
596+ Error _ ->
597597 return ()
598598
599599 Var Flex Nothing _ ->