This repository was archived by the owner on Jun 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Add spread element check when the last element is a spread. #673
Merged
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f65c1af
fix issue (#670)
Butter934 5d9da59
formatting issue
butterunderflow c1088fe
rename to improve readability
butterunderflow 1a7c3f2
comment on the boolean value indicates spread expr
butterunderflow a903246
formatting issue
butterunderflow d1c004c
fix syntax error in error message
butterunderflow 3a40a82
update CHANGELOG.md
butterunderflow 3c642cc
tweak
cristianoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3716,6 +3716,14 @@ and parseSpreadExprRegion p = | |
| _ -> None | ||
|
||
and parseListExpr ~startPos p = | ||
let check_all_non_spread_exp exprs = | ||
exprs | ||
|> List.map (fun (spread, expr) -> | ||
if spread then | ||
Parser.err p (Diagnostics.message ErrorMessages.listExprSpread); | ||
expr) | ||
|> List.rev | ||
in | ||
let listExprs = | ||
parseCommaDelimitedReversedList p ~grammar:Grammar.ListExpr ~closing:Rbrace | ||
~f:parseSpreadExprRegion | ||
|
@@ -3724,17 +3732,10 @@ and parseListExpr ~startPos p = | |
let loc = mkLoc startPos p.prevEndPos in | ||
match listExprs with | ||
| (true, expr) :: exprs -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps add comment |
||
let exprs = exprs |> List.map snd |> List.rev in | ||
let exprs = check_all_non_spread_exp exprs in | ||
makeListExpression loc exprs (Some expr) | ||
| exprs -> | ||
let exprs = | ||
exprs | ||
|> List.map (fun (spread, expr) -> | ||
if spread then | ||
Parser.err p (Diagnostics.message ErrorMessages.listExprSpread); | ||
expr) | ||
|> List.rev | ||
in | ||
let exprs = check_all_non_spread_exp exprs in | ||
makeListExpression loc exprs None | ||
|
||
(* Overparse ... and give a nice error message *) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.