• Simon Peyton Jones's avatar
    Implememt -fdefer-type-errors (Trac #5624) · 5508ada4
    Simon Peyton Jones authored
    This patch implements the idea of deferring (most) type errors to
    runtime, instead emitting only a warning at compile time.  The
    basic idea is very simple:
    
     * The on-the-fly unifier in TcUnify never fails; instead if it
       gets stuck it emits a constraint.
    
     * The constraint solver tries to solve the constraints (and is
       entirely unchanged, hooray).
    
     * The remaining, unsolved constraints (if any) are passed to
       TcErrors.reportUnsolved.  With -fdefer-type-errors, instead of
       emitting an error message, TcErrors emits a warning, AND emits
       a binding for the constraint witness, binding it
       to (error "the error message"), via the new form of evidence
       TcEvidence.EvDelayedError.  So, when the program is run,
       when (and only when) that witness is needed, the program will
       crash with the exact same error message that would have been
       given at compile time.
    
    Simple really.  But, needless to say, the exercise forced me
    into some major refactoring.
    
     * TcErrors is almost entirely rewritten
    
     * EvVarX and WantedEvVar have gone away entirely
    
     * ErrUtils is changed a bit:
         * New Severity field in ErrMsg
         * Renamed the type Message to MsgDoc (this change
           touches a lot of files trivially)
    
     * One minor change is that in the constraint solver we try
       NOT to combine insoluble constraints, like Int~Bool, else
       all such type errors get combined together and result in
       only one error message!
    
     * I moved some definitions from TcSMonad to TcRnTypes,
       where they seem to belong more
    5508ada4
flags.xml 93.4 KB