on master help sign in
add specific logic to handle two commas in a row in records
a051a17Evan Czaplicki
compiler/src/Reporting/Error/Syntax.hs+40
@@ -3872,6 +3872,26 @@ toRecordReport source context record startRow startCol =
3872 \ that is a reserved word. Try using a different name!"
3872 \ that is a reserved word. Try using a different name!"
3873 )
3873 )
3874
3874
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+
3875 _ ->
3895 _ ->
3876 let
3896 let
3877 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
3897 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
@@ -5237,6 +5257,26 @@ toTRecordReport source context record startRow startCol =
5237 \ that is a reserved word. Try using a different name!"
5257 \ that is a reserved word. Try using a different name!"
5238 )
5258 )
5239
5259
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+
5240 _ ->
5280 _ ->
5241 let
5281 let
5242 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)
5282 surroundings = A.Region (A.Position startRow startCol) (A.Position row col)