@@ -3310,23 +3310,54 @@ where
33103310 ) -> Result < Option < UntypedConstant > , ParseError > {
33113311 match self . maybe_one ( & Token :: LeftParen ) {
33123312 Some ( ( par_s, _) ) => {
3313- let arguments =
3314- Parser :: series_of ( self , & Parser :: parse_const_record_arg, Some ( & Token :: Comma ) ) ?;
3313+ // Check for spread syntax: Record(..base, ...)
3314+ let spread = match self . maybe_one ( & Token :: DotDot ) {
3315+ Some ( _) => {
3316+ // Parse the spread target constant
3317+ let spread_value = self . parse_const_value ( ) ?;
3318+ match spread_value {
3319+ Some ( value) => Some ( Box :: new ( value) ) ,
3320+ None => {
3321+ return parse_error (
3322+ ParseErrorType :: UnexpectedEof ,
3323+ SrcSpan :: new ( par_s, par_s + 2 ) ,
3324+ ) ;
3325+ }
3326+ }
3327+ }
3328+ None => None ,
3329+ } ;
3330+
3331+ // Parse remaining arguments after the spread (if any)
3332+ let mut arguments = vec ! [ ] ;
3333+ if ( spread. is_some ( ) && self . maybe_one ( & Token :: Comma ) . is_some ( ) ) || spread. is_none ( )
3334+ {
3335+ arguments = Parser :: series_of (
3336+ self ,
3337+ & Parser :: parse_const_record_arg,
3338+ Some ( & Token :: Comma ) ,
3339+ ) ?;
3340+ }
3341+
33153342 let ( _, par_e) = self . expect_one_following_series (
33163343 & Token :: RightParen ,
33173344 "a constant record argument" ,
33183345 ) ?;
3319- if arguments. is_empty ( ) {
3346+
3347+ // Validate that we have either arguments or a spread
3348+ if arguments. is_empty ( ) && spread. is_none ( ) {
33203349 return parse_error (
33213350 ParseErrorType :: ConstantRecordConstructorNoArguments ,
33223351 SrcSpan :: new ( par_s, par_e) ,
33233352 ) ;
33243353 }
3354+
33253355 Ok ( Some ( Constant :: Record {
33263356 location : SrcSpan { start, end : par_e } ,
33273357 module,
33283358 name,
33293359 arguments,
3360+ spread,
33303361 tag : ( ) ,
33313362 type_ : ( ) ,
33323363 field_map : None ,
@@ -3338,6 +3369,7 @@ where
33383369 module,
33393370 name,
33403371 arguments : vec ! [ ] ,
3372+ spread : None ,
33413373 tag : ( ) ,
33423374 type_ : ( ) ,
33433375 field_map : None ,
0 commit comments