on master help sign in
add specific logic to handle two commas in a row in records

Fix https://github.com/elm/error-message-catalog/issues/168

commita051a1789c4371727d8ddb3732170beaee0a20f9 authorEvan Czaplicki <evancz@users.noreply.github.com> dateThu 25 Jul 2019, 18:13 (7 years ago) parent302b060
1 file changed+40
compiler/src/Reporting/Error/Syntax.hs+40
compiler/src/Reporting/Error/Syntax.hs+40
@@ -3872,6 +3872,26 @@ toRecordReport source context record startRow startCol =
38723872 \ that is a reserved word. Try using a different name!"
38733873 )
38743874
3875+ Code.Other (Just ',') ->
3876+ let
3877+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3878+ region = toRegion row col
3879+ in
3880+ Report.Report "EXTRA COMMA" region [] $
3881+ Code.toSnippet source surroundings (Just region)
3882+ (
3883+ D.reflow $
3884+ "I am partway through parsing a record, but I got stuck here:"
3885+ ,
3886+ D.stack
3887+ [ D.reflow $
3888+ "I am seeing two commas in a row. This is the second one!"
3889+ , D.reflow $
3890+ "Just delete one of the commas and you should be all set!"
3891+ , noteForRecordError
3892+ ]
3893+ )
3894+
38753895 _ ->
38763896 let
38773897 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
@@ -5237,6 +5257,26 @@ toTRecordReport source context record startRow startCol =
52375257 \ that is a reserved word. Try using a different name!"
52385258 )
52395259
5260+ Code.Other (Just ',') ->
5261+ let
5262+ surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5263+ region = toRegion row col
5264+ in
5265+ Report.Report "EXTRA COMMA" region [] $
5266+ Code.toSnippet source surroundings (Just region)
5267+ (
5268+ D.reflow $
5269+ "I am partway through parsing a record type, but I got stuck here:"
5270+ ,
5271+ D.stack
5272+ [ D.reflow $
5273+ "I am seeing two commas in a row. This is the second one!"
5274+ , D.reflow $
5275+ "Just delete one of the commas and you should be all set!"
5276+ , noteForRecordTypeError
5277+ ]
5278+ )
5279+
52405280 _ ->
52415281 let
52425282 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)