on master help sign in
Move more errors up from the old commented out part
commitb439139c46c715da133c8bba7e7235fe41a76601 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 9 May 2019, 16:22 (7 years ago) parente3af26e
1 file changed+35−39
compiler/src/Reporting/Error/Syntax.hs+35−39
compiler/src/Reporting/Error/Syntax.hs+35−39
@@ -1001,10 +1001,43 @@ toDeclDefReport source name declDef startRow startCol =
10011001 toExprReport source (InDef name startRow startCol) expr row col
10021002
10031003 DeclDefNameRepeat row col ->
1004− error "TODO DeclDefNameRepeat" name row col
1004+ let
1005+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1006+ region = toRegion row col
1007+ in
1008+ Report.Report "EXPECTING DEFINITION" region [] $
1009+ Code.toSnippet source surroundings (Just region)
1010+ (
1011+ D.reflow $
1012+ "I just saw the type annotation for `" ++ Name.toChars name
1013+ ++ "` so I was expecting to see its definition here:"
1014+ ,
1015+ D.reflow $
1016+ "Type annotations always appear directly above the relevant\
1017+ \ definition, without anything else (even doc comments) in between."
1018+ )
10051019
10061020 DeclDefNameMatch defName row col ->
1007− error "TODO DeclDefNameMatch" name defName row col
1021+ let
1022+ expected = Name.toChars name
1023+ actual = Name.toChars defName
1024+
1025+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1026+ region = toRegion row col
1027+ in
1028+ Report.Report "NAME MISMATCH" region [] $
1029+ Code.toSnippet source surroundings (Just region)
1030+ (
1031+ D.reflow $
1032+ "I got stuck after parsing the `" ++ expected ++ "` type annotation:"
1033+ ,
1034+ D.stack
1035+ [ D.reflow $
1036+ "I am seeing `" ++ actual ++ "` defined next. These names do not match! Is there a typo?"
1037+ , D.indent 4 $ D.fillSep $
1038+ [D.dullyellow (D.fromChars actual),"->",D.green (D.fromChars expected)]
1039+ ]
1040+ )
10081041
10091042 DeclDefIndentType row col ->
10101043 error "TODO DeclDefIndentType" row col
@@ -2597,41 +2630,4 @@ toFuncReport source context func startRow startCol =
25972630 "Equality on floats can be unreliable, so you usually want to check that they\
25982631 \ are nearby with some sort of (abs (actual - expected) < 0.001) check."
25992632 )
2600−
2601− -- Parse.Expression
2602−
2603− MatchingName name ->
2604− Report.Report "EXPECTING A DEFINITION" region [] $
2605− Code.toSnippet source region Nothing
2606− (
2607− D.reflow $
2608− "I just saw the type annotation for `" ++ Name.toChars name
2609− ++ "` so I was expecting to see its definition here:"
2610− ,
2611− D.reflow $
2612− "Type annotations always appear directly above the relevant\
2613− \ definition, without anything else (even doc comments) in between."
2614− )
2615−-}
2616−
2617−{-
2618−
2619− TypeWithBadDefinition region annName defName ->
2620− Report.Report "ANNOTATION MISMATCH" region [] $
2621− Code.toSnippet source region Nothing
2622− (
2623− D.reflow $
2624− "I see a `" <> Name.toChars annName
2625− <> "` annotation, but it is followed by a `"
2626− <> Name.toChars defName <> "` definition."
2627− ,
2628− D.fillSep
2629− ["The","annotation","and","definition","names","must","match!"
2630− ,"Is","there","a","typo","between"
2631− , D.dullyellow (D.fromName annName)
2632− ,"and"
2633− , D.dullyellow (D.fromName defName) <> "?"
2634− ]
2635− )
2636−
26372633-}