Changes between Version 2 and Version 3 of DeferErrorsToRuntime


Ignore:
Timestamp:
Dec 21, 2011 9:03:31 AM (4 years ago)
Author:
dreixel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeferErrorsToRuntime

    v2 v3  
    33
    44This page describes the `-fwarn-type-errors` flag, currently implemented in the ghc branch `ghc-defer`.
     5
     6== Overview ==
     7While developing, sometimes it is desirable to allow compilation to succeed even
     8if there are type errors in the code. Consider the following case:
     9{{{
     10  module Main where
     11
     12  a :: Int
     13  a = 'a'
     14
     15  main = print "b"
     16}}}
     17Even though `a` is ill-typed, it is not used in the end, so if all that we're
     18interested in is `main` it is handy to be able to ignore the problems in `a`.
     19
     20Since we treat type equalities as evidence, this is relatively simple. Whenever
     21we run into a type mismatch in TcUnify, we would normally just emit an error. But it
     22is always safe to defer the mismatch to the main constraint solver. If we do
     23that, `a` will get transformed into
     24{{{
     25  $co :: Int ~# Char
     26  $co = ...
     27
     28  a :: Int
     29  a = 'a' `cast` $co
     30}}}
     31The constraint solver would realize that `co` is an insoluble constraint, and
     32emit an error. But we can also replace the right-hand side
     33of `co` with a runtime error call. This allows the program
     34to compile, and it will run fine unless we evaluate `a`. Since coercions are
     35unboxed they will be eagerly evaluated if used, so laziness will not "get on
     36the way".
     37
     38== Implementation details ==
     39
     40To do.