on master help sign in
Show source strings in error messages when possible
20047ecEvan Czaplicki
compiler/Type/State.hs+7−5
@@ -51,11 +51,13 @@ addError span message t1 t2 =
51
51
52 location =
52 location =
53 case span of
53 case span of
54− NoSpan -> ""
54+ NoSpan msg -> if null msg then "" else "in\n\n " ++ msg
55− Span p1 p2 ->
55+ Span p1 p2 msg -> lineNum ++ expr
56+ where
56− if line p1 == line p2 then "on line " ++ show (line p1)
57+ lineNum = if line p1 == line p2 then "on line " ++ show (line p1)
57− else "between lines " ++ show (line p1) ++ " and " ++ show (line p2)
58+ else "between lines " ++ show (line p1) ++ " and " ++ show (line p2)
58−
59+ expr = if null msg then "" else "\n\n " ++ msg
60+
59 makeError pt1 pt2 =
61 makeError pt1 pt2 =
60 P.vcat [ P.text $ "Type error " ++ location
62 P.vcat [ P.text $ "Type error " ++ location
61 , if null message then empty else P.vcat . map P.text $ lines message
63 , if null message then empty else P.vcat . map P.text $ lines message