on master help sign in
Propagate errors / possibly fix unranked crash!

I think I figured out the “not unranked” meta issue!!! https://github.com/elm-lang/elm-compiler/issues/1613 CONTEXT: When types fail to unify, they become Error. Error means we can avoid displaying cascading errors and only show the actually broken thing. BEFORE: In unification, we just quit when we saw an Error and some other type. No cascade! No obvious problem! AFTER: We actually need to propagate the Error in unification. If a type must unify with an Error, we CANNOT be confident that this will succeed once the Error is fixed. So it needs to be an Error too to avoid all bad cascades. But more importantly for this bug, the `merge` function produces a variable with (min rank1 rank2) as its rank! I think the root of the bug was skipping that `min` call when there are very particular cascading errors. Fixes https://github.com/elm-lang/elm-compiler/issues/1525 Fixes https://github.com/elm-lang/elm-compiler/issues/1600 Fixes https://github.com/elm-lang/elm-compiler/issues/1609 Fixes https://github.com/elm-lang/elm-compiler/issues/1582 Fixes https://github.com/elm-lang/elm-compiler/issues/1638 Fixes https://github.com/elm-lang/elm-compiler/issues/1569 Fixes https://github.com/elm-lang/elm-compiler/issues/1657 Fixes https://github.com/elm-lang/elm-compiler/issues/1607 Fixes https://github.com/elm-lang/elm-compiler/issues/1633 Fixes https://github.com/elm-lang/error-message-catalog/issues/185

commit4b25980d93ada12236c794f35570e197be82f787 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 6 Mar 2018, 14:04 (9 years ago) parent63fa090
1 file changed+6−6
compiler/src/Type/Unify.hs+6−6
compiler/src/Type/Unify.hs+6−6
@@ -215,7 +215,7 @@ actuallyUnify context@(Context _ (Descriptor firstContent _ _ _) _ (Descriptor s
215215 Error ->
216216 -- If there was an error, just pretend it is okay. This lets us avoid
217217 -- "cascading" errors where one problem manifests as multiple message.
218− return ()
218+ merge context Error
219219
220220
221221
@@ -226,7 +226,7 @@ unifyFlex :: Context -> Content -> Content -> Unify ()
226226unifyFlex context content otherContent =
227227 case otherContent of
228228 Error ->
229− return ()
229+ merge context Error
230230
231231 -- TODO see if wildcarding makes a noticable perf difference
232232
@@ -289,7 +289,7 @@ unifyRigid context maybeSuper content otherContent =
289289 mismatch
290290
291291 Error ->
292− return ()
292+ merge context Error
293293
294294
295295
@@ -348,7 +348,7 @@ unifyFlexSuper context super content otherContent =
348348 subUnify (_first context) realVar
349349
350350 Error ->
351− return ()
351+ merge context Error
352352
353353
354354combineRigidSupers :: SuperType -> SuperType -> Bool
@@ -493,7 +493,7 @@ unifyAlias context home name args realVar otherContent =
493493 subUnify realVar (_second context)
494494
495495 Error ->
496− return ()
496+ merge context Error
497497
498498
499499unifyAliasArgs :: [Variable] -> Context -> [(N.Name,Variable)] -> [(N.Name,Variable)] -> ([Variable] -> () -> IO r) -> ([Variable] -> () -> IO r) -> IO r
@@ -597,7 +597,7 @@ unifyStructure context flatType content otherContent =
597597 mismatch
598598
599599 Error ->
600− return ()
600+ merge context Error
601601
602602
603603