@@ -3292,23 +3292,54 @@ where
32923292 ) -> Result < Option < UntypedConstant > , ParseError > {
32933293 match self . maybe_one ( & Token :: LeftParen ) {
32943294 Some ( ( par_s, _) ) => {
3295- let arguments =
3296- Parser :: series_of ( self , & Parser :: parse_const_record_arg, Some ( & Token :: Comma ) ) ?;
3295+ // Check for spread syntax: Record(..base, ...)
3296+ let spread = match self . maybe_one ( & Token :: DotDot ) {
3297+ Some ( _) => {
3298+ // Parse the spread target constant
3299+ let spread_value = self . parse_const_value ( ) ?;
3300+ match spread_value {
3301+ Some ( value) => Some ( Box :: new ( value) ) ,
3302+ None => {
3303+ return parse_error (
3304+ ParseErrorType :: UnexpectedEof ,
3305+ SrcSpan :: new ( par_s, par_s + 2 ) ,
3306+ ) ;
3307+ }
3308+ }
3309+ }
3310+ None => None ,
3311+ } ;
3312+
3313+ // Parse remaining arguments after the spread (if any)
3314+ let mut arguments = vec ! [ ] ;
3315+ if ( spread. is_some ( ) && self . maybe_one ( & Token :: Comma ) . is_some ( ) ) || spread. is_none ( )
3316+ {
3317+ arguments = Parser :: series_of (
3318+ self ,
3319+ & Parser :: parse_const_record_arg,
3320+ Some ( & Token :: Comma ) ,
3321+ ) ?;
3322+ }
3323+
32973324 let ( _, par_e) = self . expect_one_following_series (
32983325 & Token :: RightParen ,
32993326 "a constant record argument" ,
33003327 ) ?;
3301- if arguments. is_empty ( ) {
3328+
3329+ // Validate that we have either arguments or a spread
3330+ if arguments. is_empty ( ) && spread. is_none ( ) {
33023331 return parse_error (
33033332 ParseErrorType :: ConstantRecordConstructorNoArguments ,
33043333 SrcSpan :: new ( par_s, par_e) ,
33053334 ) ;
33063335 }
3336+
33073337 Ok ( Some ( Constant :: Record {
33083338 location : SrcSpan { start, end : par_e } ,
33093339 module,
33103340 name,
33113341 arguments,
3342+ spread,
33123343 tag : ( ) ,
33133344 type_ : ( ) ,
33143345 field_map : None ,
@@ -3320,6 +3351,7 @@ where
33203351 module,
33213352 name,
33223353 arguments : vec ! [ ] ,
3354+ spread : None ,
33233355 tag : ( ) ,
33243356 type_ : ( ) ,
33253357 field_map : None ,
0 commit comments