on master help sign in
try to improve error for bad record field names

tweak for https://github.com/elm/error-message-catalog/issues/220

commitfea01868937a0dce6e5e490414578c2701ea571f authorEvan Czaplicki <evancz@users.noreply.github.com> dateMon 29 Jul 2019, 20:56 (7 years ago) parent311619a
1 file changed+18−8
compiler/src/Reporting/Error/Syntax.hs+18−8
compiler/src/Reporting/Error/Syntax.hs+18−8
@@ -3897,15 +3897,22 @@ toRecordReport source context record startRow startCol =
38973897 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
38983898 region = toRegion row col
38993899 in
3900− Report.Report "UNFINISHED RECORD" region [] $
3900+ Report.Report "PROBLEM IN RECORD" region [] $
39013901 Code.toSnippet source surroundings (Just region)
39023902 (
39033903 D.reflow $
39043904 "I just started parsing a record, but I got stuck here:"
39053905 ,
3906− D.fillSep
3907− ["Records","look","like",D.dullyellow "{ x = 3, y = 4 },"
3908− ,"so","I","was","expecting","to","see","a","field","name","next."
3906+ D.stack
3907+ [ D.fillSep
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
39093916 ]
39103917 )
39113918
@@ -3914,7 +3921,7 @@ toRecordReport source context record startRow startCol =
39143921 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
39153922 region = toRegion row col
39163923 in
3917− Report.Report "UNFINISHED RECORD" region [] $
3924+ Report.Report "PROBLEM IN RECORD" region [] $
39183925 Code.toSnippet source surroundings (Just region)
39193926 (
39203927 D.reflow $
@@ -4002,9 +4009,12 @@ toRecordReport source context record startRow startCol =
40024009 D.stack
40034010 [ D.fillSep
40044011 ["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"
40064013 ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
40074014 ]
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."
40084018 , noteForRecordError
40094019 ]
40104020 )
@@ -4014,7 +4024,7 @@ toRecordReport source context record startRow startCol =
40144024 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
40154025 region = toRegion row col
40164026 in
4017− Report.Report "UNFINISHED RECORD" region [] $
4027+ Report.Report "PROBLEM IN RECORD" region [] $
40184028 Code.toSnippet source surroundings (Just region)
40194029 (
40204030 D.reflow $
@@ -5428,7 +5438,7 @@ toTRecordReport source context record startRow startCol =
54285438 D.stack
54295439 [ D.fillSep
54305440 ["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"
54325442 ,D.dullyellow "userName","or",D.dullyellow "plantHeight" <> "."
54335443 ]
54345444 , noteForRecordTypeError