on master help sign in
try to improve error for bad record field names
fea0186Evan Czaplicki
compiler/src/Reporting/Error/Syntax.hs+18−8
@@ -3897,15 +3897,22 @@ toRecordReport source context record startRow startCol =
3897 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3897 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3898 region = toRegion row col
3898 region = toRegion row col
3899 in
3899 in
3900− Report.Report "UNFINISHED RECORD" region [] $
3900+ Report.Report "PROBLEM IN RECORD" region [] $
3901 Code.toSnippet source surroundings (Just region)
3901 Code.toSnippet source surroundings (Just region)
3902 (
3902 (
3903 D.reflow $
3903 D.reflow $
3904 "I just started parsing a record, but I got stuck here:"
3904 "I just started parsing a record, but I got stuck here:"
3905 ,
3905 ,
3906+ D.stack
3906− D.fillSep
3907+ [ D.fillSep
3907− ["Records","look","like",D.dullyellow "{ x = 3, y = 4 },"
3908− ,"so","I","was","expecting","to","see","a","field","name","next."
3908+ ["I","was","expecting","to","see","a","record","field","defined","next,"
3909+ ,"so","I","am","looking","for","a","name","like"
3910+ ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
3911+ ]
3912+ , D.toSimpleNote $
3913+ "Field names must start with a lower-case letter. After that, you can use\
3914+ \ any sequence of letters, numbers, and underscores."
3915+ , noteForRecordError
3909 ]
3916 ]
3910 )
3917 )
3911
3918
@@ -3914,7 +3921,7 @@ toRecordReport source context record startRow startCol =
3914 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3921 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3915 region = toRegion row col
3922 region = toRegion row col
3916 in
3923 in
3917− Report.Report "UNFINISHED RECORD" region [] $
3924+ Report.Report "PROBLEM IN RECORD" region [] $
3918 Code.toSnippet source surroundings (Just region)
3925 Code.toSnippet source surroundings (Just region)
3919 (
3926 (
3920 D.reflow $
3927 D.reflow $
@@ -4002,9 +4009,12 @@ toRecordReport source context record startRow startCol =
4002 D.stack
4009 D.stack
4003 [ D.fillSep
4010 [ D.fillSep
4004 ["I","was","expecting","to","see","another","record","field","defined","next,"
4011 ["I","was","expecting","to","see","another","record","field","defined","next,"
4005− ,"so","I","am","looking","for","a","lower-case","name","like"
4012+ ,"so","I","am","looking","for","a","name","like"
4006 ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
4013 ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
4007 ]
4014 ]
4015+ , D.toSimpleNote $
4016+ "Field names must start with a lower-case letter. After that, you can use\
4017+ \ any sequence of letters, numbers, and underscores."
4008 , noteForRecordError
4018 , noteForRecordError
4009 ]
4019 ]
4010 )
4020 )
@@ -4014,7 +4024,7 @@ toRecordReport source context record startRow startCol =
4014 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4024 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
4015 region = toRegion row col
4025 region = toRegion row col
4016 in
4026 in
4017− Report.Report "UNFINISHED RECORD" region [] $
4027+ Report.Report "PROBLEM IN RECORD" region [] $
4018 Code.toSnippet source surroundings (Just region)
4028 Code.toSnippet source surroundings (Just region)
4019 (
4029 (
4020 D.reflow $
4030 D.reflow $
@@ -5428,7 +5438,7 @@ toTRecordReport source context record startRow startCol =
5428 D.stack
5438 D.stack
5429 [ D.fillSep
5439 [ D.fillSep
5430 ["I","was","expecting","to","see","another","record","field","defined","next,"
5440 ["I","was","expecting","to","see","another","record","field","defined","next,"
5431− ,"so","I","am","looking","for","a","lower-case","name","like"
5441+ ,"so","I","am","looking","for","a","name","like"
5432 ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
5442 ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
5433 ]
5443 ]
5434 , noteForRecordTypeError
5444 , noteForRecordTypeError