on master help sign in
Switch to Code.toSnippet and detect keywords in record fields and lambda args
0bdcdd8Evan Czaplicki
compiler/src/Reporting/Error/Syntax.hs+206−149
@@ -39,7 +39,6 @@ module Reporting.Error.Syntax
39 , Number(..)
39 , Number(..)
40 --
40 --
41 , Space(..)
41 , Space(..)
42− , Operator(..)
43 , toReport
42 , toReport
44 )
43 )
45 where
44 where
@@ -53,6 +52,7 @@ import Numeric (showHex)
53
52
54import qualified Elm.ModuleName as ModuleName
53import qualified Elm.ModuleName as ModuleName
55import Parse.Primitives (Row, Col)
54import Parse.Primitives (Row, Col)
55+import Parse.Symbol (BadOperator(..))
56import qualified Reporting.Annotation as A
56import qualified Reporting.Annotation as A
57import qualified Reporting.Doc as D
57import qualified Reporting.Doc as D
58import qualified Reporting.Report as Report
58import qualified Reporting.Report as Report
@@ -118,7 +118,7 @@ data Exposing
118 | ExposingStart Row Col
118 | ExposingStart Row Col
119 | ExposingValue Row Col
119 | ExposingValue Row Col
120 | ExposingOperator Row Col
120 | ExposingOperator Row Col
121− | ExposingOperatorReserved Operator Row Col
121+ | ExposingOperatorReserved BadOperator Row Col
122 | ExposingOperatorRightParen Row Col
122 | ExposingOperatorRightParen Row Col
123 | ExposingEnd Row Col
123 | ExposingEnd Row Col
124 --
124 --
@@ -229,7 +229,7 @@ data Expr
229 | Dot Row Col
229 | Dot Row Col
230 | Access Row Col
230 | Access Row Col
231 | OperatorRight Name.Name Row Col
231 | OperatorRight Name.Name Row Col
232− | OperatorReserved Operator Row Col
232+ | OperatorReserved BadOperator Row Col
233 --
233 --
234 | Start Row Col
234 | Start Row Col
235 | Char Char Row Col
235 | Char Char Row Col
@@ -262,7 +262,7 @@ data Tuple
262 | TupleSpace Space Row Col
262 | TupleSpace Space Row Col
263 | TupleEnd Row Col
263 | TupleEnd Row Col
264 | TupleOperatorClose Row Col
264 | TupleOperatorClose Row Col
265− | TupleOperatorReserved Operator Row Col
265+ | TupleOperatorReserved BadOperator Row Col
266 --
266 --
267 | TupleIndentExpr1 Row Col
267 | TupleIndentExpr1 Row Col
268 | TupleIndentExprN Row Col
268 | TupleIndentExprN Row Col
@@ -498,14 +498,6 @@ data Space
498 | EndlessMultiComment
498 | EndlessMultiComment
499
499
500
500
501−data Operator
502− = OpDot
503− | OpPipe
504− | OpArrow
505− | OpEquals
506− | OpHasType
507−
508−
509
501
510-- TO REPORT
502-- TO REPORT
511
503
@@ -536,7 +528,7 @@ toReport source err =
536
528
537 ModuleNameMismatch expectedName (A.At region actualName) ->
529 ModuleNameMismatch expectedName (A.At region actualName) ->
538 Report.Report "MODULE NAME MISMATCH" region [ModuleName.toChars expectedName] $
530 Report.Report "MODULE NAME MISMATCH" region [ModuleName.toChars expectedName] $
539− Report.toCodeSnippet source region Nothing
531+ Code.toSnippet source region Nothing
540 (
532 (
541 "It looks like this module name is out of sync:"
533 "It looks like this module name is out of sync:"
542 ,
534 ,
@@ -575,7 +567,7 @@ toParseErrorReport source modul =
575 region = toRegion row col
567 region = toRegion row col
576 in
568 in
577 Report.Report "EXPECTING END OF FILE" region [] $
569 Report.Report "EXPECTING END OF FILE" region [] $
578− Report.toCodeSnippet source region Nothing
570+ Code.toSnippet source region Nothing
579 (
571 (
580 D.reflow $
572 D.reflow $
581 "I was not expecting to see anything more here:"
573 "I was not expecting to see anything more here:"
@@ -659,7 +651,7 @@ toParseErrorReport source modul =
659 region = toRegion row col
651 region = toRegion row col
660 in
652 in
661 Report.Report "UNFINISHED IMPORT" region [] $
653 Report.Report "UNFINISHED IMPORT" region [] $
662− Report.toCodeSnippet source region Nothing
654+ Code.toSnippet source region Nothing
663 (
655 (
664 D.reflow $
656 D.reflow $
665 "I was parsing an `import` until I got stuck here:"
657 "I was parsing an `import` until I got stuck here:"
@@ -683,7 +675,7 @@ toParseErrorReport source modul =
683 region = toRegion row col
675 region = toRegion row col
684 in
676 in
685 Report.Report "BAD INFIX" region [] $
677 Report.Report "BAD INFIX" region [] $
686− Report.toCodeSnippet source region Nothing
678+ Code.toSnippet source region Nothing
687 (
679 (
688 D.reflow $
680 D.reflow $
689 "Something went wrong in this infix operator declaration:"
681 "Something went wrong in this infix operator declaration:"
@@ -705,7 +697,7 @@ toSpaceReport source space row col =
705 region = toRegion row col
697 region = toRegion row col
706 in
698 in
707 Report.Report "NO TABS" region [] $
699 Report.Report "NO TABS" region [] $
708− Report.toCodeSnippet source region Nothing
700+ Code.toSnippet source region Nothing
709 (
701 (
710 D.reflow $
702 D.reflow $
711 "I ran into a tab, but tabs are not allowed in Elm files."
703 "I ran into a tab, but tabs are not allowed in Elm files."
@@ -719,7 +711,7 @@ toSpaceReport source space row col =
719 region = toWiderRegion row col 2
711 region = toWiderRegion row col 2
720 in
712 in
721 Report.Report "ENDLESS COMMENT" region [] $
713 Report.Report "ENDLESS COMMENT" region [] $
722− Report.toCodeSnippet source region Nothing
714+ Code.toSnippet source region Nothing
723 (
715 (
724 D.reflow $
716 D.reflow $
725 "I cannot find the end of this multi-line comment:"
717 "I cannot find the end of this multi-line comment:"
@@ -876,7 +868,7 @@ toExprReport source context expr startRow startCol =
876 Dot row col ->
868 Dot row col ->
877 let region = toRegion row col in
869 let region = toRegion row col in
878 Report.Report "EXPECTING RECORD ACCESSOR" region [] $
870 Report.Report "EXPECTING RECORD ACCESSOR" region [] $
879− Report.toCodeSnippet source region Nothing
871+ Code.toSnippet source region Nothing
880 (
872 (
881 D.reflow $
873 D.reflow $
882 "I was expecting to see a record accessor here:"
874 "I was expecting to see a record accessor here:"
@@ -890,7 +882,7 @@ toExprReport source context expr startRow startCol =
890 Access row col ->
882 Access row col ->
891 let region = toRegion row col in
883 let region = toRegion row col in
892 Report.Report "EXPECTING RECORD ACCESSOR" region [] $
884 Report.Report "EXPECTING RECORD ACCESSOR" region [] $
893− Report.toCodeSnippet source region Nothing
885+ Code.toSnippet source region Nothing
894 (
886 (
895 D.reflow $
887 D.reflow $
896 "I am trying to parse a record accessor here:"
888 "I am trying to parse a record accessor here:"
@@ -910,7 +902,7 @@ toExprReport source context expr startRow startCol =
910 OperatorRight op row col ->
902 OperatorRight op row col ->
911 let region = toRegion row col in
903 let region = toRegion row col in
912 Report.Report "MISSING EXPRESSION" region [] $
904 Report.Report "MISSING EXPRESSION" region [] $
913− Report.toCodeSnippet source region Nothing
905+ Code.toSnippet source region Nothing
914 (
906 (
915 D.reflow $
907 D.reflow $
916 "I was expecting to see an expression after this " ++ Name.toChars op ++ " operator:"
908 "I was expecting to see an expression after this " ++ Name.toChars op ++ " operator:"
@@ -950,7 +942,7 @@ toExprReport source context expr startRow startCol =
950 region = toRegion row col
942 region = toRegion row col
951 in
943 in
952 Report.Report "MISSING EXPRESSION" region [] $
944 Report.Report "MISSING EXPRESSION" region [] $
953− Report.toCodeSnippet source surroundings (Just region)
945+ Code.toSnippet source surroundings (Just region)
954 (
946 (
955 D.reflow $
947 D.reflow $
956 "I am partway through parsing " ++ aThing ++ ", but I got stuck here:"
948 "I am partway through parsing " ++ aThing ++ ", but I got stuck here:"
@@ -986,7 +978,7 @@ toExprReport source context expr startRow startCol =
986 region = toWiderRegion row col 6
978 region = toWiderRegion row col 6
987 in
979 in
988 Report.Report "ENDLESS SHADER" region [] $
980 Report.Report "ENDLESS SHADER" region [] $
989− Report.toCodeSnippet source region Nothing
981+ Code.toSnippet source region Nothing
990 (
982 (
991 D.reflow "I cannot find the end of this shader:"
983 D.reflow "I cannot find the end of this shader:"
992 ,
984 ,
@@ -998,7 +990,7 @@ toExprReport source context expr startRow startCol =
998 region = toRegion row col
990 region = toRegion row col
999 in
991 in
1000 Report.Report "SHADER PROBLEM" region [] $
992 Report.Report "SHADER PROBLEM" region [] $
1001− Report.toCodeSnippet source region Nothing
993+ Code.toSnippet source region Nothing
1002 (
994 (
1003 D.reflow $
995 D.reflow $
1004 "I ran into a problem while parsing this GLSL block."
996 "I ran into a problem while parsing this GLSL block."
@@ -1017,7 +1009,7 @@ toExprReport source context expr startRow startCol =
1017 region = toRegion row col
1009 region = toRegion row col
1018 in
1010 in
1019 Report.Report "MISSING EXPRESSION" region [] $
1011 Report.Report "MISSING EXPRESSION" region [] $
1020− Report.toCodeSnippet source surroundings (Just region)
1012+ Code.toSnippet source surroundings (Just region)
1021 (
1013 (
1022 D.reflow $
1014 D.reflow $
1023 "I was expecting to see an expression after this " ++ Name.toChars op ++ " operator:"
1015 "I was expecting to see an expression after this " ++ Name.toChars op ++ " operator:"
@@ -1042,6 +1034,10 @@ toExprReport source context expr startRow startCol =
1042 error "TODO IndentMoreExpr"
1034 error "TODO IndentMoreExpr"
1043
1035
1044
1036
1037+
1038+-- CHAR
1039+
1040+
1045toCharReport :: Code.Source -> Char -> Row -> Col -> Report.Report
1041toCharReport :: Code.Source -> Char -> Row -> Col -> Report.Report
1046toCharReport source char row col =
1042toCharReport source char row col =
1047 case char of
1043 case char of
@@ -1050,7 +1046,7 @@ toCharReport source char row col =
1050 region = toRegion row col
1046 region = toRegion row col
1051 in
1047 in
1052 Report.Report "MISSING SINGLE QUOTE" region [] $
1048 Report.Report "MISSING SINGLE QUOTE" region [] $
1053− Report.toCodeSnippet source region Nothing
1049+ Code.toSnippet source region Nothing
1054 (
1050 (
1055 D.reflow $
1051 D.reflow $
1056 "I thought I was parsing a character, but I got to the end of\
1052 "I thought I was parsing a character, but I got to the end of\
@@ -1068,7 +1064,7 @@ toCharReport source char row col =
1068 region = toWiderRegion row col width
1064 region = toWiderRegion row col width
1069 in
1065 in
1070 Report.Report "NEEDS DOUBLE QUOTES" region [] $
1066 Report.Report "NEEDS DOUBLE QUOTES" region [] $
1071− Report.toCodeSnippet source region Nothing
1067+ Code.toSnippet source region Nothing
1072 (
1068 (
1073 "The following string uses single quotes:"
1069 "The following string uses single quotes:"
1074 ,
1070 ,
@@ -1085,6 +1081,10 @@ toCharReport source char row col =
1085 )
1081 )
1086
1082
1087
1083
1084+
1085+-- STRING
1086+
1087+
1088toStringReport :: Code.Source -> String -> Row -> Col -> Report.Report
1088toStringReport :: Code.Source -> String -> Row -> Col -> Report.Report
1089toStringReport source string row col =
1089toStringReport source string row col =
1090 case string of
1090 case string of
@@ -1093,7 +1093,7 @@ toStringReport source string row col =
1093 region = toRegion row col
1093 region = toRegion row col
1094 in
1094 in
1095 Report.Report "ENDLESS STRING" region [] $
1095 Report.Report "ENDLESS STRING" region [] $
1096− Report.toCodeSnippet source region Nothing
1096+ Code.toSnippet source region Nothing
1097 (
1097 (
1098 D.reflow $
1098 D.reflow $
1099 "I got to the end of the line without seeing the closing double quote:"
1099 "I got to the end of the line without seeing the closing double quote:"
@@ -1113,7 +1113,7 @@ toStringReport source string row col =
1113 region = toWiderRegion row col 3
1113 region = toWiderRegion row col 3
1114 in
1114 in
1115 Report.Report "ENDLESS STRING" region [] $
1115 Report.Report "ENDLESS STRING" region [] $
1116− Report.toCodeSnippet source region Nothing
1116+ Code.toSnippet source region Nothing
1117 (
1117 (
1118 D.reflow $
1118 D.reflow $
1119 "I cannot find the end of this multi-line string:"
1119 "I cannot find the end of this multi-line string:"
@@ -1128,6 +1128,10 @@ toStringReport source string row col =
1128 toEscapeReport source escape row col
1128 toEscapeReport source escape row col
1129
1129
1130
1130
1131+
1132+-- ESCAPES
1133+
1134+
1131toEscapeReport :: Code.Source -> Escape -> Row -> Col -> Report.Report
1135toEscapeReport :: Code.Source -> Escape -> Row -> Col -> Report.Report
1132toEscapeReport source escape row col =
1136toEscapeReport source escape row col =
1133 case escape of
1137 case escape of
@@ -1136,7 +1140,7 @@ toEscapeReport source escape row col =
1136 region = toWiderRegion row col 2
1140 region = toWiderRegion row col 2
1137 in
1141 in
1138 Report.Report "UNKNOWN ESCAPE" region [] $
1142 Report.Report "UNKNOWN ESCAPE" region [] $
1139− Report.toCodeSnippet source region Nothing
1143+ Code.toSnippet source region Nothing
1140 (
1144 (
1141 D.reflow $
1145 D.reflow $
1142 "Backslashes always start escaped characters, but I do not recognize this one:"
1146 "Backslashes always start escaped characters, but I do not recognize this one:"
@@ -1167,7 +1171,7 @@ toEscapeReport source escape row col =
1167 region = toWiderRegion row col width
1171 region = toWiderRegion row col width
1168 in
1172 in
1169 Report.Report "BAD UNICODE ESCAPE" region [] $
1173 Report.Report "BAD UNICODE ESCAPE" region [] $
1170− Report.toCodeSnippet source region Nothing
1174+ Code.toSnippet source region Nothing
1171 (
1175 (
1172 D.reflow $
1176 D.reflow $
1173 "I ran into an invalid Unicode escape:"
1177 "I ran into an invalid Unicode escape:"
@@ -1191,7 +1195,7 @@ toEscapeReport source escape row col =
1191 region = toWiderRegion row col width
1195 region = toWiderRegion row col width
1192 in
1196 in
1193 Report.Report "BAD UNICODE ESCAPE" region [] $
1197 Report.Report "BAD UNICODE ESCAPE" region [] $
1194− Report.toCodeSnippet source region Nothing
1198+ Code.toSnippet source region Nothing
1195 (
1199 (
1196 D.reflow $
1200 D.reflow $
1197 "This is not a valid code point:"
1201 "This is not a valid code point:"
@@ -1205,7 +1209,7 @@ toEscapeReport source escape row col =
1205 region = toWiderRegion row col width
1209 region = toWiderRegion row col width
1206 in
1210 in
1207 Report.Report "BAD UNICODE ESCAPE" region [] $
1211 Report.Report "BAD UNICODE ESCAPE" region [] $
1208− Report.toCodeSnippet source region Nothing $
1212+ Code.toSnippet source region Nothing $
1209 if numDigits < 4 then
1213 if numDigits < 4 then
1210 (
1214 (
1211 D.reflow $
1215 D.reflow $
@@ -1232,6 +1236,10 @@ toEscapeReport source escape row col =
1232 )
1236 )
1233
1237
1234
1238
1239+
1240+-- NUMBERS
1241+
1242+
1235toNumberReport :: Code.Source -> Number -> Row -> Col -> Report.Report
1243toNumberReport :: Code.Source -> Number -> Row -> Col -> Report.Report
1236toNumberReport source number row col =
1244toNumberReport source number row col =
1237 let
1245 let
@@ -1240,7 +1248,7 @@ toNumberReport source number row col =
1240 case number of
1248 case number of
1241 NumberEnd ->
1249 NumberEnd ->
1242 Report.Report "WEIRD NUMBER" region [] $
1250 Report.Report "WEIRD NUMBER" region [] $
1243− Report.toCodeSnippet source region Nothing
1251+ Code.toSnippet source region Nothing
1244 (
1252 (
1245 D.reflow $
1253 D.reflow $
1246 "I thought I was reading a number, but I ran into some weird stuff here:"
1254 "I thought I was reading a number, but I ran into some weird stuff here:"
@@ -1256,7 +1264,7 @@ toNumberReport source number row col =
1256
1264
1257 NumberDot int ->
1265 NumberDot int ->
1258 Report.Report "WEIRD NUMBER" region [] $
1266 Report.Report "WEIRD NUMBER" region [] $
1259− Report.toCodeSnippet source region Nothing
1267+ Code.toSnippet source region Nothing
1260 (
1268 (
1261 D.reflow $
1269 D.reflow $
1262 "Numbers cannot end with a dot like this:"
1270 "Numbers cannot end with a dot like this:"
@@ -1270,7 +1278,7 @@ toNumberReport source number row col =
1270
1278
1271 NumberHexDigit ->
1279 NumberHexDigit ->
1272 Report.Report "WEIRD HEXIDECIMAL" region [] $
1280 Report.Report "WEIRD HEXIDECIMAL" region [] $
1273− Report.toCodeSnippet source region Nothing
1281+ Code.toSnippet source region Nothing
1274 (
1282 (
1275 D.reflow $
1283 D.reflow $
1276 "I thought I was reading a hexidecimal number until I got here:"
1284 "I thought I was reading a hexidecimal number until I got here:"
@@ -1285,7 +1293,7 @@ toNumberReport source number row col =
1285
1293
1286 NumberNoLeadingZero ->
1294 NumberNoLeadingZero ->
1287 Report.Report "LEADING ZEROS" region [] $
1295 Report.Report "LEADING ZEROS" region [] $
1288− Report.toCodeSnippet source region Nothing
1296+ Code.toSnippet source region Nothing
1289 (
1297 (
1290 D.reflow $
1298 D.reflow $
1291 "I do not accept numbers with leading zeros:"
1299 "I do not accept numbers with leading zeros:"
@@ -1303,15 +1311,19 @@ toNumberReport source number row col =
1303 )
1311 )
1304
1312
1305
1313
1314+
1315+-- OPERATORS
1316+
1317+
1306−toOperatorReport :: Code.Source -> Context -> Operator -> Row -> Col -> Report.Report
1318+toOperatorReport :: Code.Source -> Context -> BadOperator -> Row -> Col -> Report.Report
1307toOperatorReport source context operator row col =
1319toOperatorReport source context operator row col =
1308 case operator of
1320 case operator of
1309− OpDot ->
1321+ BadDot ->
1310 let
1322 let
1311 region = toRegion row col
1323 region = toRegion row col
1312 in
1324 in
1313 Report.Report "UNEXPECTED SYMBOL" region [] $
1325 Report.Report "UNEXPECTED SYMBOL" region [] $
1314− Report.toCodeSnippet source region Nothing
1326+ Code.toSnippet source region Nothing
1315 (
1327 (
1316 "I was not expecting this dot:"
1328 "I was not expecting this dot:"
1317 ,
1329 ,
@@ -1321,12 +1333,12 @@ toOperatorReport source context operator row col =
1321 \ there is some extra whitespace?"
1333 \ there is some extra whitespace?"
1322 )
1334 )
1323
1335
1324− OpPipe ->
1336+ BadPipe ->
1325 let
1337 let
1326 region = toRegion row col
1338 region = toRegion row col
1327 in
1339 in
1328 Report.Report "UNEXPECTED SYMBOL" region [] $
1340 Report.Report "UNEXPECTED SYMBOL" region [] $
1329− Report.toCodeSnippet source region Nothing
1341+ Code.toSnippet source region Nothing
1330 (
1342 (
1331 D.reflow $
1343 D.reflow $
1332 "I was not expecting this vertical bar:"
1344 "I was not expecting this vertical bar:"
@@ -1335,12 +1347,12 @@ toOperatorReport source context operator row col =
1335 "Vertical bars should only appear in custom type declarations. Maybe you want || instead?"
1347 "Vertical bars should only appear in custom type declarations. Maybe you want || instead?"
1336 )
1348 )
1337
1349
1338− OpArrow ->
1350+ BadArrow ->
1339 let
1351 let
1340 region = toWiderRegion row col 2
1352 region = toWiderRegion row col 2
1341 in
1353 in
1342 Report.Report "UNEXPECTED ARROW" region [] $
1354 Report.Report "UNEXPECTED ARROW" region [] $
1343− Report.toCodeSnippet source region Nothing $
1355+ Code.toSnippet source region Nothing $
1344 if error "TODO inCase" then
1356 if error "TODO inCase" then
1345 (
1357 (
1346 D.reflow $
1358 D.reflow $
@@ -1370,13 +1382,13 @@ toOperatorReport source context operator row col =
1370 \ you want > or >= instead?"
1382 \ you want > or >= instead?"
1371 )
1383 )
1372
1384
1373− OpEquals ->
1385+ BadEquals ->
1374 let
1386 let
1375 region = toRegion row col
1387 region = toRegion row col
1376 name = getDefName context
1388 name = getDefName context
1377 in
1389 in
1378 Report.Report "UNEXPECTED EQUALS" region [] $
1390 Report.Report "UNEXPECTED EQUALS" region [] $
1379− Report.toCodeSnippet source region Nothing
1391+ Code.toSnippet source region Nothing
1380 (
1392 (
1381 D.reflow $
1393 D.reflow $
1382 "I was not expecting to see this equals sign:"
1394 "I was not expecting to see this equals sign:"
@@ -1398,13 +1410,13 @@ toOperatorReport source context operator row col =
1398 ]
1410 ]
1399 )
1411 )
1400
1412
1401− OpHasType ->
1413+ BadHasType ->
1402 let
1414 let
1403 region = toRegion row col
1415 region = toRegion row col
1404 name = getDefName context
1416 name = getDefName context
1405 in
1417 in
1406 Report.Report "UNEXPECTED SYMBOL" region [] $
1418 Report.Report "UNEXPECTED SYMBOL" region [] $
1407− Report.toCodeSnippet source region Nothing $
1419+ Code.toSnippet source region Nothing $
1408 (
1420 (
1409 D.reflow $
1421 D.reflow $
1410 "I was not expecting to run into the \"has type\" symbol here:"
1422 "I was not expecting to run into the \"has type\" symbol here:"
@@ -1445,7 +1457,7 @@ toIfReport source context if_ startRow startCol =
1445 region = toRegion row col
1457 region = toRegion row col
1446 in
1458 in
1447 Report.Report "UNFINISHED IF" region [] $
1459 Report.Report "UNFINISHED IF" region [] $
1448− Report.toCodeSnippet source surroundings (Just region)
1460+ Code.toSnippet source surroundings (Just region)
1449 (
1461 (
1450 D.reflow $
1462 D.reflow $
1451 "I was expecting to see more of this `if` expression, but I got stuck here:"
1463 "I was expecting to see more of this `if` expression, but I got stuck here:"
@@ -1461,7 +1473,7 @@ toIfReport source context if_ startRow startCol =
1461 region = toRegion row col
1473 region = toRegion row col
1462 in
1474 in
1463 Report.Report "UNFINISHED IF" region [] $
1475 Report.Report "UNFINISHED IF" region [] $
1464− Report.toCodeSnippet source surroundings (Just region)
1476+ Code.toSnippet source surroundings (Just region)
1465 (
1477 (
1466 D.reflow $
1478 D.reflow $
1467 "I was expecting to see more of this `if` expression, but I got stuck here:"
1479 "I was expecting to see more of this `if` expression, but I got stuck here:"
@@ -1477,7 +1489,7 @@ toIfReport source context if_ startRow startCol =
1477 region = toRegion row col
1489 region = toRegion row col
1478 in
1490 in
1479 Report.Report "UNFINISHED IF" region [] $
1491 Report.Report "UNFINISHED IF" region [] $
1480− Report.toCodeSnippet source surroundings (Just region)
1492+ Code.toSnippet source surroundings (Just region)
1481 (
1493 (
1482 D.reflow $
1494 D.reflow $
1483 "I just saw the start of an `else` branch, but then I got stuck here:"
1495 "I just saw the start of an `else` branch, but then I got stuck here:"
@@ -1501,7 +1513,7 @@ toIfReport source context if_ startRow startCol =
1501 region = toRegion row col
1513 region = toRegion row col
1502 in
1514 in
1503 Report.Report "UNFINISHED IF" region [] $
1515 Report.Report "UNFINISHED IF" region [] $
1504− Report.toCodeSnippet source surroundings (Just region)
1516+ Code.toSnippet source surroundings (Just region)
1505 (
1517 (
1506 D.reflow $
1518 D.reflow $
1507 "I was expecting to see more of this `if` expression, but I got stuck here:"
1519 "I was expecting to see more of this `if` expression, but I got stuck here:"
@@ -1522,7 +1534,7 @@ toIfReport source context if_ startRow startCol =
1522 region = toRegion row col
1534 region = toRegion row col
1523 in
1535 in
1524 Report.Report "UNFINISHED IF" region [] $
1536 Report.Report "UNFINISHED IF" region [] $
1525− Report.toCodeSnippet source surroundings (Just region)
1537+ Code.toSnippet source surroundings (Just region)
1526 (
1538 (
1527 D.reflow $
1539 D.reflow $
1528 "I was expecting to see more of this `if` expression, but I got stuck here:"
1540 "I was expecting to see more of this `if` expression, but I got stuck here:"
@@ -1542,7 +1554,7 @@ toIfReport source context if_ startRow startCol =
1542 region = toRegion row col
1554 region = toRegion row col
1543 in
1555 in
1544 Report.Report "UNFINISHED IF" region [] $
1556 Report.Report "UNFINISHED IF" region [] $
1545− Report.toCodeSnippet source surroundings (Just region)
1557+ Code.toSnippet source surroundings (Just region)
1546 (
1558 (
1547 D.reflow $
1559 D.reflow $
1548 "I got stuck after the start of this `then` branch:"
1560 "I got stuck after the start of this `then` branch:"
@@ -1562,7 +1574,7 @@ toIfReport source context if_ startRow startCol =
1562 region = toRegion row col
1574 region = toRegion row col
1563 in
1575 in
1564 Report.Report "UNFINISHED IF" region [] $
1576 Report.Report "UNFINISHED IF" region [] $
1565− Report.toCodeSnippet source surroundings (Just region)
1577+ Code.toSnippet source surroundings (Just region)
1566 (
1578 (
1567 D.reflow $
1579 D.reflow $
1568 "I got stuck after the start of this `else` branch:"
1580 "I got stuck after the start of this `else` branch:"
@@ -1582,7 +1594,7 @@ toIfReport source context if_ startRow startCol =
1582 region = toRegion row col
1594 region = toRegion row col
1583 in
1595 in
1584 Report.Report "UNFINISHED IF" region [] $
1596 Report.Report "UNFINISHED IF" region [] $
1585− Report.toCodeSnippet source surroundings (Just region)
1597+ Code.toSnippet source surroundings (Just region)
1586 (
1598 (
1587 D.reflow $
1599 D.reflow $
1588 "I was expecting to see an `else` branch after this:"
1600 "I was expecting to see an `else` branch after this:"
@@ -1608,38 +1620,51 @@ toRecordReport source context record startRow startCol =
1608 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1620 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1609 region = toRegion row col
1621 region = toRegion row col
1610 in
1622 in
1623+ case Code.whatIsNext source row col of
1624+ Keyword keyword ->
1625+ Report.Report "RESERVED WORD" region [] $
1626+ Code.toSnippet source surroundings (Just region)
1627+ (
1628+ D.reflow $
1629+ "I just started parsing a record, but I got stuck on this field name:"
1630+ ,
1631+ D.reflow $
1632+ "It looks like you are trying to use `" ++ keyword ++ "` as a field name, but \
1633+ \ that is a reserved word. Try using a different name!"
1634+ )
1635+
1636+ _ ->
1611− Report.Report "UNFINISHED PARENTHESES" region [] $
1637+ Report.Report "UNFINISHED RECORD" region [] $
1612− Report.toCodeSnippet source surroundings (Just region)
1638+ Code.toSnippet source surroundings (Just region)
1613− (
1639+ (
1614− D.reflow $
1640+ D.reflow $
1615− "I was expecting to see a closing curly brace next, but I got stuck here:"
1641+ "I just started parsing a record, but I got stuck here:"
1616− ,
1642+ ,
1617− D.stack
1643+ D.fillSep
1618− [ D.fillSep ["Try","adding","a",D.dullyellow "}","to","see","if","that","helps?"]
1644+ ["Records","look","like",D.dullyellow "{ x = 3, y = 4 },"
1619− , D.toSimpleNote $
1645+ ,"so","I","was","expecting","to","see","a","field","name","next."
1620− "I can get stuck when I run into keywords, operators, parentheses, or brackets\
1621− \ unexpectedly. So there may be some other syntax trouble (like an extra\
1622− \ parenthesis?) that is confusing me."
1623− ]
1646+ ]
1624− )
1647+ )
1625
1648
1626 RecordEnd row col ->
1649 RecordEnd row col ->
1627 let
1650 let
1628 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1651 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1629 region = toRegion row col
1652 region = toRegion row col
1630 in
1653 in
1631− Report.Report "UNFINISHED PARENTHESES" region [] $
1654+ Report.Report "UNFINISHED RECORD" region [] $
1632− Report.toCodeSnippet source surroundings (Just region)
1655+ Code.toSnippet source surroundings (Just region)
1633 (
1656 (
1634 D.reflow $
1657 D.reflow $
1635− "I was expecting to see a closing curly brace next, but I got stuck here:"
1658+ "I am partway through parsing a record, but I got stuck here:"
1636 ,
1659 ,
1637 D.stack
1660 D.stack
1661+ [ D.fillSep
1662+ ["I","was","expecting","to","see","a","closing","curly","brace","before","this,"
1638− [ D.fillSep ["Try","adding","a",D.dullyellow "}","to","see","if","that","helps?"]
1663+ ,"so","try","adding","a",D.dullyellow "}","and","see","if","that","helps?"
1664+ ]
1639 , D.toSimpleNote $
1665 , D.toSimpleNote $
1640− "I can get stuck when I run into keywords, operators, parentheses, or brackets\
1666+ "When I get stuck like this, it usually means that there is a missing parenthesis\
1641− \ unexpectedly. So there may be some other syntax trouble (like an extra\
1667+ \ or bracket somewhere earlier. It could also be a stray keyword or operator."
1642− \ parenthesis?) that is confusing me."
1643 ]
1668 ]
1644 )
1669 )
1645
1670
@@ -1648,18 +1673,32 @@ toRecordReport source context record startRow startCol =
1648 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1673 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
1649 region = toRegion row col
1674 region = toRegion row col
1650 in
1675 in
1676+ case Code.whatIsNext source row col of
1677+ Code.Keyword keyword ->
1678+ Report.Report "RESERVED WORD" region [] $
1679+ Code.toSnippet source surroundings (Just region)
1680+ (
1681+ D.reflow $
1682+ "I am partway through parsing a record, but I got stuck on this field name:"
1683+ ,
1684+ D.reflow $
1685+ "It looks like you are trying to use `" ++ keyword ++ "` as a field name, but \
1686+ \ that is a reserved word. Try using a different name!"
1687+ )
1688+
1689+ _ ->
1651− Report.Report "UNFINISHED RECORD" region [] $
1690+ Report.Report "UNFINISHED RECORD" region [] $
1652− Report.toCodeSnippet source surroundings (Just region)
1691+ Code.toSnippet source surroundings (Just region)
1653− (
1692+ (
1654− D.reflow $
1693+ D.reflow $
1655− "I am partway through parsing a record, but I got stuck after that last comma:"
1694+ "I am partway through parsing a record, but I got stuck after that last comma:"
1656− ,
1695+ ,
1657− addNoteForRecordError $
1696+ addNoteForRecordError $
1658− D.reflow $
1697+ D.reflow $
1659− "Trailing commas are not allowed in records, so I was expecting to see another\
1698+ "Trailing commas are not allowed in records, so I was expecting to see another\
1660− \ record field defined next. If you are done defining the record, the fix may\
1699+ \ record field defined next. If you are done defining the record, the fix may\
1661− \ be to delete that last comma?"
1700+ \ be to delete that last comma?"
1662− )
1701+ )
1663
1702
1664 RecordEquals row col ->
1703 RecordEquals row col ->
1665 let
1704 let
@@ -1667,7 +1706,7 @@ toRecordReport source context record startRow startCol =
1667 region = toRegion row col
1706 region = toRegion row col
1668 in
1707 in
1669 Report.Report "UNFINISHED RECORD" region [] $
1708 Report.Report "UNFINISHED RECORD" region [] $
1670− Report.toCodeSnippet source surroundings (Just region)
1709+ Code.toSnippet source surroundings (Just region)
1671 (
1710 (
1672 D.reflow $
1711 D.reflow $
1673 "I am partway through parsing a record, but I got stuck here:"
1712 "I am partway through parsing a record, but I got stuck here:"
@@ -1691,7 +1730,7 @@ toRecordReport source context record startRow startCol =
1691 region = toRegion row col
1730 region = toRegion row col
1692 in
1731 in
1693 Report.Report "UNFINISHED RECORD" region [] $
1732 Report.Report "UNFINISHED RECORD" region [] $
1694− Report.toCodeSnippet source surroundings (Just region)
1733+ Code.toSnippet source surroundings (Just region)
1695 (
1734 (
1696 D.reflow $
1735 D.reflow $
1697 "I just saw the opening curly brace of a record, but then I got stuck here:"
1736 "I just saw the opening curly brace of a record, but then I got stuck here:"
@@ -1709,7 +1748,7 @@ toRecordReport source context record startRow startCol =
1709 region = toRegion row col
1748 region = toRegion row col
1710 in
1749 in
1711 Report.Report "UNFINISHED RECORD" region [] $
1750 Report.Report "UNFINISHED RECORD" region [] $
1712− Report.toCodeSnippet source surroundings (Just region)
1751+ Code.toSnippet source surroundings (Just region)
1713 (
1752 (
1714 D.reflow $
1753 D.reflow $
1715 "I was expecting to see a closing curly brace next:"
1754 "I was expecting to see a closing curly brace next:"
@@ -1726,7 +1765,7 @@ toRecordReport source context record startRow startCol =
1726 region = toRegion row col
1765 region = toRegion row col
1727 in
1766 in
1728 Report.Report "UNFINISHED RECORD" region [] $
1767 Report.Report "UNFINISHED RECORD" region [] $
1729− Report.toCodeSnippet source surroundings (Just region)
1768+ Code.toSnippet source surroundings (Just region)
1730 (
1769 (
1731 D.reflow $
1770 D.reflow $
1732 "I am partway through parsing a record, but I got stuck after that last comma:"
1771 "I am partway through parsing a record, but I got stuck after that last comma:"
@@ -1744,7 +1783,7 @@ toRecordReport source context record startRow startCol =
1744 region = toRegion row col
1783 region = toRegion row col
1745 in
1784 in
1746 Report.Report "UNFINISHED RECORD" region [] $
1785 Report.Report "UNFINISHED RECORD" region [] $
1747− Report.toCodeSnippet source surroundings (Just region)
1786+ Code.toSnippet source surroundings (Just region)
1748 (
1787 (
1749 D.reflow $
1788 D.reflow $
1750 "I am partway through parsing a record. I just saw a record\
1789 "I am partway through parsing a record. I just saw a record\
@@ -1762,7 +1801,7 @@ toRecordReport source context record startRow startCol =
1762 region = toRegion row col
1801 region = toRegion row col
1763 in
1802 in
1764 Report.Report "UNFINISHED RECORD" region [] $
1803 Report.Report "UNFINISHED RECORD" region [] $
1765− Report.toCodeSnippet source surroundings (Just region)
1804+ Code.toSnippet source surroundings (Just region)
1766 (
1805 (
1767 D.reflow $
1806 D.reflow $
1768 "I am partway through parsing a record, and I was expecting to run into an expression next:"
1807 "I am partway through parsing a record, and I was expecting to run into an expression next:"
@@ -1835,7 +1874,7 @@ toTupleReport source context tuple startRow startCol =
1835 region = toRegion row col
1874 region = toRegion row col
1836 in
1875 in
1837 Report.Report "UNFINISHED PARENTHESES" region [] $
1876 Report.Report "UNFINISHED PARENTHESES" region [] $
1838− Report.toCodeSnippet source surroundings (Just region)
1877+ Code.toSnippet source surroundings (Just region)
1839 (
1878 (
1840 D.reflow $
1879 D.reflow $
1841 "I was expecting to see a closing parentheses next, but I got stuck here:"
1880 "I was expecting to see a closing parentheses next, but I got stuck here:"
@@ -1844,8 +1883,8 @@ toTupleReport source context tuple startRow startCol =
1844 [ D.fillSep ["Try","adding","a",D.dullyellow ")","to","see","if","that","helps?"]
1883 [ D.fillSep ["Try","adding","a",D.dullyellow ")","to","see","if","that","helps?"]
1845 , D.toSimpleNote $
1884 , D.toSimpleNote $
1846 "I can get stuck when I run into keywords, operators, parentheses, or brackets\
1885 "I can get stuck when I run into keywords, operators, parentheses, or brackets\
1847− \ unexpectedly. So there may be some other syntax trouble (like an extra\
1886+ \ unexpectedly. So there may be some earlier syntax trouble (like extra parenthesis\
1848− \ square bracket?) that is confusing me."
1887+ \ or missing brackets) that is confusing me."
1849 ]
1888 ]
1850 )
1889 )
1851
1890
@@ -1855,7 +1894,7 @@ toTupleReport source context tuple startRow startCol =
1855 region = toRegion row col
1894 region = toRegion row col
1856 in
1895 in
1857 Report.Report "UNFINISHED OPERATOR FUNCTION" region [] $
1896 Report.Report "UNFINISHED OPERATOR FUNCTION" region [] $
1858− Report.toCodeSnippet source surroundings (Just region)
1897+ Code.toSnippet source surroundings (Just region)
1859 (
1898 (
1860 D.reflow "I was expecting a closing parenthesis here:"
1899 D.reflow "I was expecting a closing parenthesis here:"
1861 ,
1900 ,
@@ -1874,18 +1913,18 @@ toTupleReport source context tuple startRow startCol =
1874 region = toRegion row col
1913 region = toRegion row col
1875 in
1914 in
1876 Report.Report "UNEXPECTED SYMBOL" region [] $
1915 Report.Report "UNEXPECTED SYMBOL" region [] $
1877− Report.toCodeSnippet source surroundings (Just region)
1916+ Code.toSnippet source surroundings (Just region)
1878 (
1917 (
1879 D.reflow $
1918 D.reflow $
1880 "I ran into an unexpected symbol here:"
1919 "I ran into an unexpected symbol here:"
1881 ,
1920 ,
1882 D.fillSep $
1921 D.fillSep $
1883 case operator of
1922 case operator of
1884− OpDot -> ["Maybe","you","wanted","a","record","accessor","like",D.dullyellow ".x","or",D.dullyellow ".name","instead?"]
1923+ BadDot -> ["Maybe","you","wanted","a","record","accessor","like",D.dullyellow ".x","or",D.dullyellow ".name","instead?"]
1885− OpPipe -> ["Try",D.dullyellow "(||)","instead?","To","turn","boolean","OR","into","a","function?"]
1924+ BadPipe -> ["Try",D.dullyellow "(||)","instead?","To","turn","boolean","OR","into","a","function?"]
1886− OpArrow -> ["Maybe","you","wanted",D.dullyellow "(>)","or",D.dullyellow "(>=)","instead?"]
1925+ BadArrow -> ["Maybe","you","wanted",D.dullyellow "(>)","or",D.dullyellow "(>=)","instead?"]
1887− OpEquals -> ["Try",D.dullyellow "(==)","instead?","To","make","a","function","that","checks","equality?"]
1926+ BadEquals -> ["Try",D.dullyellow "(==)","instead?","To","make","a","function","that","checks","equality?"]
1888− OpHasType -> ["Try",D.dullyellow "(::)","instead?","To","add","values","to","the","front","of","lists?"]
1927+ BadHasType -> ["Try",D.dullyellow "(::)","instead?","To","add","values","to","the","front","of","lists?"]
1889 )
1928 )
1890
1929
1891 TupleIndentExpr1 row col ->
1930 TupleIndentExpr1 row col ->
@@ -1894,7 +1933,7 @@ toTupleReport source context tuple startRow startCol =
1894 region = toRegion row col
1933 region = toRegion row col
1895 in
1934 in
1896 Report.Report "UNFINISHED PARENTHESES" region [] $
1935 Report.Report "UNFINISHED PARENTHESES" region [] $
1897− Report.toCodeSnippet source surroundings (Just region)
1936+ Code.toSnippet source surroundings (Just region)
1898 (
1937 (
1899 D.reflow $
1938 D.reflow $
1900 "I just saw an open parenthesis, so I was expecting to see an expression next."
1939 "I just saw an open parenthesis, so I was expecting to see an expression next."
@@ -1917,7 +1956,7 @@ toTupleReport source context tuple startRow startCol =
1917 region = toRegion row col
1956 region = toRegion row col
1918 in
1957 in
1919 Report.Report "UNFINISHED TUPLE" region [] $
1958 Report.Report "UNFINISHED TUPLE" region [] $
1920− Report.toCodeSnippet source surroundings (Just region)
1959+ Code.toSnippet source surroundings (Just region)
1921 (
1960 (
1922 D.reflow $
1961 D.reflow $
1923 "I think I am in the middle of parsing a tuple. I just saw a comma, so I was expecting to see expression next."
1962 "I think I am in the middle of parsing a tuple. I just saw a comma, so I was expecting to see expression next."
@@ -1940,7 +1979,7 @@ toTupleReport source context tuple startRow startCol =
1940 region = toRegion row col
1979 region = toRegion row col
1941 in
1980 in
1942 Report.Report "UNFINISHED PARENTHESES" region [] $
1981 Report.Report "UNFINISHED PARENTHESES" region [] $
1943− Report.toCodeSnippet source surroundings (Just region)
1982+ Code.toSnippet source surroundings (Just region)
1944 (
1983 (
1945 D.reflow $
1984 D.reflow $
1946 "I was expecting to see a closing parenthesis next:"
1985 "I was expecting to see a closing parenthesis next:"
@@ -1966,17 +2005,19 @@ toListReport source context list startRow startCol =
1966 region = toRegion row col
2005 region = toRegion row col
1967 in
2006 in
1968 Report.Report "UNFINISHED LIST" region [] $
2007 Report.Report "UNFINISHED LIST" region [] $
1969− Report.toCodeSnippet source surroundings (Just region)
2008+ Code.toSnippet source surroundings (Just region)
1970 (
2009 (
1971 D.reflow $
2010 D.reflow $
1972− "I was expecting to see a closing square bracket next, but I got stuck here:"
2011+ "I am partway through parsing a list, but I got stuck here:"
1973 ,
2012 ,
1974 D.stack
2013 D.stack
2014+ [ D.fillSep
2015+ ["I","was","expecting","to","see","a","closing","square","bracket","before","this,"
1975− [ D.fillSep ["Try","adding","a",D.dullyellow "]","to","see","if","that","helps?"]
2016+ ,"so","try","adding","a",D.dullyellow "]","and","see","if","that","helps?"
2017+ ]
1976 , D.toSimpleNote $
2018 , D.toSimpleNote $
1977− "I can get stuck when I run into keywords, operators, parentheses, or brackets\
2019+ "When I get stuck like this, it usually means that there is a missing parenthesis\
1978− \ unexpectedly. So there may be some other syntax trouble (like an extra\
2020+ \ or bracket somewhere earlier. It could also be a stray keyword or operator."
1979− \ parenthesis?) that is confusing me."
1980 ]
2021 ]
1981 )
2022 )
1982
2023
@@ -1988,7 +2029,7 @@ toListReport source context list startRow startCol =
1988 region = toRegion r c
2029 region = toRegion r c
1989 in
2030 in
1990 Report.Report "UNFINISHED LIST" region [] $
2031 Report.Report "UNFINISHED LIST" region [] $
1991− Report.toCodeSnippet source surroundings (Just region)
2032+ Code.toSnippet source surroundings (Just region)
1992 (
2033 (
1993 D.reflow $
2034 D.reflow $
1994 "I was expecting to see another list entry after that last comma:"
2035 "I was expecting to see another list entry after that last comma:"
@@ -2020,17 +2061,19 @@ toListReport source context list startRow startCol =
2020 region = toRegion row col
2061 region = toRegion row col
2021 in
2062 in
2022 Report.Report "UNFINISHED LIST" region [] $
2063 Report.Report "UNFINISHED LIST" region [] $
2023− Report.toCodeSnippet source surroundings (Just region)
2064+ Code.toSnippet source surroundings (Just region)
2024 (
2065 (
2025 D.reflow $
2066 D.reflow $
2026− "I was expecting to see a closing square bracket next, but I got stuck here:"
2067+ "I am partway through parsing a list, but I got stuck here:"
2027 ,
2068 ,
2028 D.stack
2069 D.stack
2070+ [ D.fillSep
2071+ ["I","was","expecting","to","see","a","closing","square","bracket","before","this,"
2029− [ D.fillSep ["Try","adding","a",D.dullyellow "]","to","see","if","that","helps?"]
2072+ ,"so","try","adding","a",D.dullyellow "]","and","see","if","that","helps?"
2073+ ]
2030 , D.toSimpleNote $
2074 , D.toSimpleNote $
2031− "I can get stuck when I run into keywords, operators, parentheses, or brackets\
2075+ "When I get stuck like this, it usually means that there is a missing parenthesis\
2032− \ unexpectedly. So there may be some other syntax trouble (like an extra\
2076+ \ or bracket somewhere earlier. It could also be a stray keyword or operator."
2033− \ parenthesis?) that is confusing me."
2034 ]
2077 ]
2035 )
2078 )
2036
2079
@@ -2040,7 +2083,7 @@ toListReport source context list startRow startCol =
2040 region = toRegion row col
2083 region = toRegion row col
2041 in
2084 in
2042 Report.Report "UNFINISHED LIST" region [] $
2085 Report.Report "UNFINISHED LIST" region [] $
2043− Report.toCodeSnippet source surroundings (Just region)
2086+ Code.toSnippet source surroundings (Just region)
2044 (
2087 (
2045 D.reflow $
2088 D.reflow $
2046 "I cannot find the end of this list:"
2089 "I cannot find the end of this list:"
@@ -2076,7 +2119,7 @@ toListReport source context list startRow startCol =
2076 region = toRegion row col
2119 region = toRegion row col
2077 in
2120 in
2078 Report.Report "UNFINISHED LIST" region [] $
2121 Report.Report "UNFINISHED LIST" region [] $
2079− Report.toCodeSnippet source surroundings (Just region)
2122+ Code.toSnippet source surroundings (Just region)
2080 (
2123 (
2081 D.reflow $
2124 D.reflow $
2082 "I cannot find the end of this list:"
2125 "I cannot find the end of this list:"
@@ -2108,7 +2151,7 @@ toListReport source context list startRow startCol =
2108 region = toRegion row col
2151 region = toRegion row col
2109 in
2152 in
2110 Report.Report "UNFINISHED LIST" region [] $
2153 Report.Report "UNFINISHED LIST" region [] $
2111− Report.toCodeSnippet source surroundings (Just region)
2154+ Code.toSnippet source surroundings (Just region)
2112 (
2155 (
2113 D.reflow $
2156 D.reflow $
2114 "I was expecting to see another list entry after this comma:"
2157 "I was expecting to see another list entry after this comma:"
@@ -2149,18 +2192,32 @@ toFuncReport source context func startRow startCol =
2149 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
2192 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
2150 region = toRegion row col
2193 region = toRegion row col
2151 in
2194 in
2195+ case Code.whatIsNext source row col of
2196+ Code.Keyword keyword ->
2197+ Report.Report "RESERVED WORD" region [] $
2198+ Code.toSnippet source surroundings (Just region)
2199+ (
2200+ D.reflow $
2201+ "I was parsing an anonymous function, but I got stuck here:"
2202+ ,
2203+ D.reflow $
2204+ "It looks like you are trying to use `" ++ keyword ++ "` as an argument, but\
2205+ \ it is a reserved word in this language. Try using a different argument name!"
2206+ )
2207+
2208+ _ ->
2152− Report.Report "UNFINISHED ANONYMOUS FUNCTION" region [] $
2209+ Report.Report "UNFINISHED ANONYMOUS FUNCTION" region [] $
2153− Report.toCodeSnippet source surroundings (Just region)
2210+ Code.toSnippet source surroundings (Just region)
2154− (
2211+ (
2155− D.reflow $
2212+ D.reflow $
2156− "I just saw the beginning of an anonymous function, so I was expecting to see an arrow next:"
2213+ "I just saw the beginning of an anonymous function, so I was expecting to see an arrow next:"
2157− ,
2214+ ,
2158− D.fillSep $
2215+ D.fillSep $
2159− ["The","syntax","for","anonymous","functions","is"
2216+ ["The","syntax","for","anonymous","functions","is"
2160− ,D.dullyellow "(\\x -> x + 1)"
2217+ ,D.dullyellow "(\\x -> x + 1)"
2161− ,"so","I","am","missing","the","arrow","and","the","body","of","the","function."
2218+ ,"so","I","am","missing","the","arrow","and","the","body","of","the","function."
2162− ]
2219+ ]
2163− )
2220+ )
2164
2221
2165 FuncIndentArg row col ->
2222 FuncIndentArg row col ->
2166 let
2223 let
@@ -2168,7 +2225,7 @@ toFuncReport source context func startRow startCol =
2168 region = toRegion row col
2225 region = toRegion row col
2169 in
2226 in
2170 Report.Report "MISSING ARGUMENT" region [] $
2227 Report.Report "MISSING ARGUMENT" region [] $
2171− Report.toCodeSnippet source surroundings (Just region)
2228+ Code.toSnippet source surroundings (Just region)
2172 (
2229 (
2173 D.reflow $
2230 D.reflow $
2174 "I just saw the beginning of an anonymous function, so I was expecting to see an argument next:"
2231 "I just saw the beginning of an anonymous function, so I was expecting to see an argument next:"
@@ -2191,7 +2248,7 @@ toFuncReport source context func startRow startCol =
2191 region = toRegion row col
2248 region = toRegion row col
2192 in
2249 in
2193 Report.Report "UNFINISHED ANONYMOUS FUNCTION" region [] $
2250 Report.Report "UNFINISHED ANONYMOUS FUNCTION" region [] $
2194− Report.toCodeSnippet source surroundings (Just region)
2251+ Code.toSnippet source surroundings (Just region)
2195 (
2252 (
2196 D.reflow $
2253 D.reflow $
2197 "I just saw the beginning of an anonymous function, so I was expecting to see an arrow next:"
2254 "I just saw the beginning of an anonymous function, so I was expecting to see an arrow next:"
@@ -2216,7 +2273,7 @@ toFuncReport source context func startRow startCol =
2216 region = toRegion row col
2273 region = toRegion row col
2217 in
2274 in
2218 Report.Report "UNFINISHED ANONYMOUS FUNCTION" region [] $
2275 Report.Report "UNFINISHED ANONYMOUS FUNCTION" region [] $
2219− Report.toCodeSnippet source surroundings (Just region)
2276+ Code.toSnippet source surroundings (Just region)
2220 (
2277 (
2221 D.reflow $
2278 D.reflow $
2222 "I was expecting to see the body of your anonymous function next:"
2279 "I was expecting to see the body of your anonymous function next:"
@@ -2242,7 +2299,7 @@ toFuncReport source context func startRow startCol =
2242 case err of
2299 case err of
2243 CommentOnNothing region ->
2300 CommentOnNothing region ->
2244 Report.Report "STRAY COMMENT" region [] $
2301 Report.Report "STRAY COMMENT" region [] $
2245− Report.toCodeSnippet source region Nothing
2302+ Code.toSnippet source region Nothing
2246 (
2303 (
2247 "This documentation comment is not followed by anything."
2304 "This documentation comment is not followed by anything."
2248 ,
2305 ,
@@ -2254,7 +2311,7 @@ toFuncReport source context func startRow startCol =
2254
2311
2255 UnexpectedPort region ->
2312 UnexpectedPort region ->
2256 Report.Report "UNEXPECTED PORTS" region [] $
2313 Report.Report "UNEXPECTED PORTS" region [] $
2257− Report.toCodeSnippet source region Nothing
2314+ Code.toSnippet source region Nothing
2258 (
2315 (
2259 D.reflow $
2316 D.reflow $
2260 "You are declaring ports in a normal module."
2317 "You are declaring ports in a normal module."
@@ -2273,7 +2330,7 @@ toFuncReport source context func startRow startCol =
2273
2330
2274 NoPorts region ->
2331 NoPorts region ->
2275 Report.Report "NO PORTS" region [] $
2332 Report.Report "NO PORTS" region [] $
2276− Report.toCodeSnippet source region Nothing
2333+ Code.toSnippet source region Nothing
2277 (
2334 (
2278 D.reflow $
2335 D.reflow $
2279 "This module does not declare any ports, but it says it will:"
2336 "This module does not declare any ports, but it says it will:"
@@ -2293,7 +2350,7 @@ toFuncReport source context func startRow startCol =
2293
2350
2294 DocComment ->
2351 DocComment ->
2295 Report.Report "EXPECTING DOC COMMENT" region [] $
2352 Report.Report "EXPECTING DOC COMMENT" region [] $
2296− Report.toCodeSnippet source region Nothing
2353+ Code.toSnippet source region Nothing
2297 (
2354 (
2298 D.reflow $
2355 D.reflow $
2299 "I was expecting a doc comment here:"
2356 "I was expecting a doc comment here:"
@@ -2306,7 +2363,7 @@ toFuncReport source context func startRow startCol =
2306
2363
2307 Precedence ->
2364 Precedence ->
2308 Report.Report "EXPECTING PRECEDENCE" region [] $
2365 Report.Report "EXPECTING PRECEDENCE" region [] $
2309− Report.toCodeSnippet source region Nothing
2366+ Code.toSnippet source region Nothing
2310 (
2367 (
2311 D.reflow $
2368 D.reflow $
2312 "I was expecting the precedence here:"
2369 "I was expecting the precedence here:"
@@ -2317,7 +2374,7 @@ toFuncReport source context func startRow startCol =
2317
2374
2318 Wildcard ->
2375 Wildcard ->
2319 Report.Report "EXPECTING A WILDCARD" region [] $
2376 Report.Report "EXPECTING A WILDCARD" region [] $
2320− Report.toCodeSnippet source region Nothing
2377+ Code.toSnippet source region Nothing
2321 (
2378 (
2322 D.reflow $
2379 D.reflow $
2323 "I was expecting a _ here:"
2380 "I was expecting a _ here:"
@@ -2333,7 +2390,7 @@ toFuncReport source context func startRow startCol =
2333 A.Region (A.Position row startCol) (A.Position row endCol)
2390 A.Region (A.Position row startCol) (A.Position row endCol)
2334 in
2391 in
2335 Report.Report "INVALID PATTERN" badRegion [] $
2392 Report.Report "INVALID PATTERN" badRegion [] $
2336− Report.toCodeSnippet source badRegion Nothing
2393+ Code.toSnippet source badRegion Nothing
2337 (
2394 (
2338 D.reflow $
2395 D.reflow $
2339 "I was expecting to see an underscore without any additional characters:"
2396 "I was expecting to see an underscore without any additional characters:"
@@ -2347,7 +2404,7 @@ toFuncReport source context func startRow startCol =
2347
2404
2348 FloatInPattern ->
2405 FloatInPattern ->
2349 Report.Report "INVALID PATTERN" region [] $
2406 Report.Report "INVALID PATTERN" region [] $
2350− Report.toCodeSnippet source region Nothing
2407+ Code.toSnippet source region Nothing
2351 (
2408 (
2352 D.reflow $
2409 D.reflow $
2353 "I cannot pattern match with floating point numbers:"
2410 "I cannot pattern match with floating point numbers:"
@@ -2361,7 +2418,7 @@ toFuncReport source context func startRow startCol =
2361
2418
2362 MatchingName name ->
2419 MatchingName name ->
2363 Report.Report "EXPECTING A DEFINITION" region [] $
2420 Report.Report "EXPECTING A DEFINITION" region [] $
2364− Report.toCodeSnippet source region Nothing
2421+ Code.toSnippet source region Nothing
2365 (
2422 (
2366 D.reflow $
2423 D.reflow $
2367 "I just saw the type annotation for `" ++ Name.toChars name
2424 "I just saw the type annotation for `" ++ Name.toChars name
@@ -2377,7 +2434,7 @@ toFuncReport source context func startRow startCol =
2377
2434
2378 TypeWithBadDefinition region annName defName ->
2435 TypeWithBadDefinition region annName defName ->
2379 Report.Report "ANNOTATION MISMATCH" region [] $
2436 Report.Report "ANNOTATION MISMATCH" region [] $
2380− Report.toCodeSnippet source region Nothing
2437+ Code.toSnippet source region Nothing
2381 (
2438 (
2382 D.reflow $
2439 D.reflow $
2383 "I see a `" <> Name.toChars annName
2440 "I see a `" <> Name.toChars annName