on master help sign in
Show source strings in error messages when possible
commit20047ec0eb35ebf8d07f7293176f876fb80c7e6b authorEvan Czaplicki <info@elm-lang.org> dateSat 3 Aug 2013, 11:41 (13 years ago) parent51bc878
1 file changed+7−5
compiler/Type/State.hs+7−5
compiler/Type/State.hs+7−5
@@ -51,11 +51,13 @@ addError span message t1 t2 =
5151
5252 location =
5353 case span of
54− NoSpan -> ""
55− Span p1 p2 ->
56− if line p1 == line p2 then "on line " ++ show (line p1)
57− else "between lines " ++ show (line p1) ++ " and " ++ show (line p2)
58−
54+ NoSpan msg -> if null msg then "" else "in\n\n " ++ msg
55+ Span p1 p2 msg -> lineNum ++ expr
56+ where
57+ lineNum = if line p1 == line p2 then "on line " ++ show (line p1)
58+ else "between lines " ++ show (line p1) ++ " and " ++ show (line p2)
59+ expr = if null msg then "" else "\n\n " ++ msg
60+
5961 makeError pt1 pt2 =
6062 P.vcat [ P.text $ "Type error " ++ location
6163 , if null message then empty else P.vcat . map P.text $ lines message