@@ -3308,23 +3308,54 @@ where
33083308 ) -> Result < Option < UntypedConstant > , ParseError > {
33093309 match self . maybe_one ( & Token :: LeftParen ) {
33103310 Some ( ( par_s, _) ) => {
3311- let arguments =
3312- Parser :: series_of ( self , & Parser :: parse_const_record_arg, Some ( & Token :: Comma ) ) ?;
3311+ // Check for spread syntax: Record(..base, ...)
3312+ let spread = match self . maybe_one ( & Token :: DotDot ) {
3313+ Some ( _) => {
3314+ // Parse the spread target constant
3315+ let spread_value = self . parse_const_value ( ) ?;
3316+ match spread_value {
3317+ Some ( value) => Some ( Box :: new ( value) ) ,
3318+ None => {
3319+ return parse_error (
3320+ ParseErrorType :: UnexpectedEof ,
3321+ SrcSpan :: new ( par_s, par_s + 2 ) ,
3322+ ) ;
3323+ }
3324+ }
3325+ }
3326+ None => None ,
3327+ } ;
3328+
3329+ // Parse remaining arguments after the spread (if any)
3330+ let mut arguments = vec ! [ ] ;
3331+ if ( spread. is_some ( ) && self . maybe_one ( & Token :: Comma ) . is_some ( ) ) || spread. is_none ( )
3332+ {
3333+ arguments = Parser :: series_of (
3334+ self ,
3335+ & Parser :: parse_const_record_arg,
3336+ Some ( & Token :: Comma ) ,
3337+ ) ?;
3338+ }
3339+
33133340 let ( _, par_e) = self . expect_one_following_series (
33143341 & Token :: RightParen ,
33153342 "a constant record argument" ,
33163343 ) ?;
3317- if arguments. is_empty ( ) {
3344+
3345+ // Validate that we have either arguments or a spread
3346+ if arguments. is_empty ( ) && spread. is_none ( ) {
33183347 return parse_error (
33193348 ParseErrorType :: ConstantRecordConstructorNoArguments ,
33203349 SrcSpan :: new ( par_s, par_e) ,
33213350 ) ;
33223351 }
3352+
33233353 Ok ( Some ( Constant :: Record {
33243354 location : SrcSpan { start, end : par_e } ,
33253355 module,
33263356 name,
33273357 arguments,
3358+ spread,
33283359 tag : ( ) ,
33293360 type_ : ( ) ,
33303361 field_map : None ,
@@ -3336,6 +3367,7 @@ where
33363367 module,
33373368 name,
33383369 arguments : vec ! [ ] ,
3370+ spread : None ,
33393371 tag : ( ) ,
33403372 type_ : ( ) ,
33413373 field_map : None ,
0 commit comments