Skip to content

Commit ff1defd

Browse files
committed
Use dedicated syntax for dotdotdot.
1 parent 9e33cc1 commit ff1defd

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

jscomp/test/DotDotDot.res

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
type a = {x: int}
22

3-
type b = {\"...": a, y: string}
3+
type b = {...a, y: string}
44

5-
type c = {\"...": b, z: string}
5+
type c = {...b, z: string}
66

77
let v: c = {x: 10, y: "", z: ""}
88

99
type vw = {v: float, w: float}
1010

11-
type cvw = {\"...": c, \"...": vw}
11+
type cvw = {...c, ...vw}
1212

1313
let v2: cvw = {x: 10, y: "", z: "", v: 1.0, w: 2.0}
1414

@@ -30,14 +30,14 @@ type anchorProps = {
3030
type divProps = {\"...": globalProps}
3131

3232
type svgProps = {
33-
\"...": globalProps,
33+
...globalProps,
3434
x?: string,
3535
y?: string,
3636
}
3737

3838
module MultipleDotDotDots = {
3939
type t1 = {x: int}
4040
type t2 = {y: string}
41-
type t = {\"...": t1, \"...": t2}
41+
type t = {...t1, ...t2}
4242
let x: t = {x: 10, y: "abc"}
4343
}

res_syntax/src/res_core.ml

-16
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ module ErrorMessages = struct
146146
"An inline record type declaration is only allowed in a variant \
147147
constructor's declaration"
148148

149-
let sameTypeSpread =
150-
"You're using a ... spread without extra fields. This is the same type."
151-
152149
let polyVarIntWithSuffix number =
153150
"A numeric polymorphic variant cannot be followed by a letter. Did you \
154151
mean `#" ^ number ^ "`?"
@@ -4094,19 +4091,10 @@ and parseRecordOrObjectType ~attrs p =
40944091
(Diagnostics.message ErrorMessages.forbiddenInlineRecordDeclaration)
40954092
| _ -> ()
40964093
in
4097-
let startFirstField = p.startPos in
40984094
let fields =
40994095
parseCommaDelimitedRegion ~grammar:Grammar.StringFieldDeclarations
41004096
~closing:Rbrace ~f:parseStringFieldDeclaration p
41014097
in
4102-
let () =
4103-
match fields with
4104-
| [Parsetree.Oinherit {ptyp_loc}] ->
4105-
(* {...x}, spread without extra fields *)
4106-
Parser.err p ~startPos:startFirstField ~endPos:ptyp_loc.loc_end
4107-
(Diagnostics.message ErrorMessages.sameTypeSpread)
4108-
| _ -> ()
4109-
in
41104098
Parser.expect Rbrace p;
41114099
let loc = mkLoc startPos p.prevEndPos in
41124100
Ast_helper.Typ.object_ ~loc ~attrs fields closedFlag
@@ -4566,8 +4554,6 @@ and parseConstrDeclArgs p =
45664554
match p.token with
45674555
| Rbrace ->
45684556
(* {...x}, spread without extra fields *)
4569-
Parser.err ~startPos:dotdotdotStart ~endPos:dotdotdotEnd p
4570-
(Diagnostics.message ErrorMessages.sameTypeSpread);
45714557
Parser.next p
45724558
| _ -> Parser.expect Comma p
45734559
in
@@ -4993,8 +4979,6 @@ and parseRecordOrObjectDecl p =
49934979
match p.token with
49944980
| Rbrace ->
49954981
(* {...x}, spread without extra fields *)
4996-
Parser.err ~startPos:dotdotdotStart ~endPos:dotdotdotEnd p
4997-
(Diagnostics.message ErrorMessages.sameTypeSpread);
49984982
Parser.next p
49994983
| _ -> Parser.expect Comma p
50004984
in

0 commit comments

Comments
 (0)