on master help sign in
Move more errors up from the old commented out part
b439139Evan Czaplicki
compiler/src/Reporting/Error/Syntax.hs+35−39
@@ -1001,10 +1001,43 @@ toDeclDefReport source name declDef startRow startCol =
1001 toExprReport source (InDef name startRow startCol) expr row col
1001 toExprReport source (InDef name startRow startCol) expr row col
1002
1002
1003 DeclDefNameRepeat row col ->
1003 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+ )
1005
1019
1006 DeclDefNameMatch defName row col ->
1020 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+ )
1008
1041
1009 DeclDefIndentType row col ->
1042 DeclDefIndentType row col ->
1010 error "TODO DeclDefIndentType" row col
1043 error "TODO DeclDefIndentType" row col
@@ -2597,41 +2630,4 @@ toFuncReport source context func startRow startCol =
2597 "Equality on floats can be unreliable, so you usually want to check that they\
2630 "Equality on floats can be unreliable, so you usually want to check that they\
2598 \ are nearby with some sort of (abs (actual - expected) < 0.001) check."
2631 \ are nearby with some sort of (abs (actual - expected) < 0.001) check."
2599 )
2632 )
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−
2637-}
2633-}