@@ -208,12 +208,12 @@ allDistinct vars =
208208 do desc <- liftIO $ UF.descriptor var
209209 case structure desc of
210210 Just _ ->
211− TS.addError (error "Cannot generalize something that is not a type variable.") undefined
211+ crash "Cannot generalize something that is not a type variable."
212212
213213 Nothing ->
214− do when (mark desc == seen) $
215− TS.addError (error "Duplicate variable during generalization.") undefined
216− liftIO $ UF.setDescriptor var (desc { mark = seen })
214+ if mark desc == seen
215+ then crash "Duplicate variable during generalization."
216+ else liftIO (UF.setDescriptor var (desc { mark = seen }))
217217
218218
219219-- Check that a variable has rank == noRank, meaning that it can be generalized.
@@ -222,8 +222,16 @@ isGeneric var =
222222 do desc <- liftIO $ UF.descriptor var
223223 if rank desc == noRank
224224 then return ()
225− else
226− TS.addError (error "Unable to generalize a type variable. It is not unranked.") undefined
225+ else crash "Unable to generalize a type variable. It is not unranked."
226+
227+
228+crash :: String -> a
229+crash msg =
230+ error $
231+ "It looks like something went wrong with the type inference algorithm.\n"
232+ ++ msg ++ "\n"
233+ ++ "Please create a minimal example that triggers this problem and report it to\n"
234+ ++ "<https://github.com/elm-lang/elm-compiler/issues>"
227235
228236
229237occurs :: (String, Variable) -> StateT TS.SolverState IO ()