@@ -3313,23 +3313,54 @@ where
33133313 ) -> Result < Option < UntypedConstant > , ParseError > {
33143314 match self . maybe_one ( & Token :: LeftParen ) {
33153315 Some ( ( par_s, _) ) => {
3316- let arguments =
3317- Parser :: series_of ( self , & Parser :: parse_const_record_arg, Some ( & Token :: Comma ) ) ?;
3316+ // Check for spread syntax: Record(..base, ...)
3317+ let spread = match self . maybe_one ( & Token :: DotDot ) {
3318+ Some ( _) => {
3319+ // Parse the spread target constant
3320+ let spread_value = self . parse_const_value ( ) ?;
3321+ match spread_value {
3322+ Some ( value) => Some ( Box :: new ( value) ) ,
3323+ None => {
3324+ return parse_error (
3325+ ParseErrorType :: UnexpectedEof ,
3326+ SrcSpan :: new ( par_s, par_s + 2 ) ,
3327+ ) ;
3328+ }
3329+ }
3330+ }
3331+ None => None ,
3332+ } ;
3333+
3334+ // Parse remaining arguments after the spread (if any)
3335+ let mut arguments = vec ! [ ] ;
3336+ if ( spread. is_some ( ) && self . maybe_one ( & Token :: Comma ) . is_some ( ) ) || spread. is_none ( )
3337+ {
3338+ arguments = Parser :: series_of (
3339+ self ,
3340+ & Parser :: parse_const_record_arg,
3341+ Some ( & Token :: Comma ) ,
3342+ ) ?;
3343+ }
3344+
33183345 let ( _, par_e) = self . expect_one_following_series (
33193346 & Token :: RightParen ,
33203347 "a constant record argument" ,
33213348 ) ?;
3322- if arguments. is_empty ( ) {
3349+
3350+ // Validate that we have either arguments or a spread
3351+ if arguments. is_empty ( ) && spread. is_none ( ) {
33233352 return parse_error (
33243353 ParseErrorType :: ConstantRecordConstructorNoArguments ,
33253354 SrcSpan :: new ( par_s, par_e) ,
33263355 ) ;
33273356 }
3357+
33283358 Ok ( Some ( Constant :: Record {
33293359 location : SrcSpan { start, end : par_e } ,
33303360 module,
33313361 name,
33323362 arguments,
3363+ spread,
33333364 tag : ( ) ,
33343365 type_ : ( ) ,
33353366 field_map : None ,
@@ -3341,6 +3372,7 @@ where
33413372 module,
33423373 name,
33433374 arguments : vec ! [ ] ,
3375+ spread : None ,
33443376 tag : ( ) ,
33453377 type_ : ( ) ,
33463378 field_map : None ,
0 commit comments