Skip to content

Commit a051a17

Browse files
committed
add specific logic to handle two commas in a row in records
Fix elm/error-message-catalog#168
1 parent 302b060 commit a051a17

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

compiler/src/Reporting/Error/Syntax.hs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

0 commit comments

Comments
 (0)