@@ -6,15 +6,15 @@ use vec1::Vec1;
66use crate :: {
77 analyse:: Inferred ,
88 ast:: {
9- Assert , AssignName , Assignment , BinOp , BitArraySize , CallArg , Constant , Definition ,
10- FunctionLiteralKind , Pattern , RecordBeingUpdated , SrcSpan , Statement , TailPattern ,
11- TargetedDefinition , TodoKind , TypeAst , TypeAstConstructor , TypeAstFn , TypeAstHole ,
12- TypeAstTuple , TypeAstVar , UntypedArg , UntypedAssert , UntypedAssignment , UntypedClause ,
13- UntypedConstant , UntypedConstantBitArraySegment , UntypedCustomType , UntypedDefinition ,
14- UntypedExpr , UntypedExprBitArraySegment , UntypedFunction , UntypedImport , UntypedModule ,
15- UntypedModuleConstant , UntypedPattern , UntypedPatternBitArraySegment ,
16- UntypedRecordUpdateArg , UntypedStatement , UntypedTailPattern , UntypedTypeAlias , UntypedUse ,
17- UntypedUseAssignment , Use , UseAssignment ,
9+ Assert , AssignName , Assignment , BinOp , BitArraySize , CallArg , Constant ,
10+ ConstantRecordUpdateArg , Definition , FunctionLiteralKind , Pattern , RecordBeingUpdated ,
11+ SrcSpan , Statement , TailPattern , TargetedDefinition , TodoKind , TypeAst , TypeAstConstructor ,
12+ TypeAstFn , TypeAstHole , TypeAstTuple , TypeAstVar , UntypedArg , UntypedAssert ,
13+ UntypedAssignment , UntypedClause , UntypedConstant , UntypedConstantBitArraySegment ,
14+ UntypedCustomType , UntypedDefinition , UntypedExpr , UntypedExprBitArraySegment ,
15+ UntypedFunction , UntypedImport , UntypedModule , UntypedModuleConstant , UntypedPattern ,
16+ UntypedPatternBitArraySegment , UntypedRecordUpdateArg , UntypedStatement ,
17+ UntypedTailPattern , UntypedTypeAlias , UntypedUse , UntypedUseAssignment , Use , UseAssignment ,
1818 } ,
1919 build:: Target ,
2020 parse:: LiteralFloatValue ,
@@ -972,12 +972,22 @@ pub trait UntypedConstantFolder {
972972 module,
973973 name,
974974 arguments,
975- spread,
976975 tag : ( ) ,
977976 type_ : ( ) ,
978977 field_map : _,
979978 record_constructor : _,
980- } => self . fold_constant_record ( location, module, name, arguments, spread) ,
979+ } => self . fold_constant_record ( location, module, name, arguments) ,
980+
981+ Constant :: RecordUpdate {
982+ location,
983+ module,
984+ name,
985+ record,
986+ arguments,
987+ tag : ( ) ,
988+ type_ : ( ) ,
989+ field_map : _,
990+ } => self . fold_constant_record_update ( location, module, name, record, arguments) ,
981991
982992 Constant :: BitArray { location, segments } => {
983993 self . fold_constant_bit_array ( location, segments)
@@ -1060,21 +1070,39 @@ pub trait UntypedConstantFolder {
10601070 module : Option < ( EcoString , SrcSpan ) > ,
10611071 name : EcoString ,
10621072 arguments : Vec < CallArg < UntypedConstant > > ,
1063- spread : Option < Box < UntypedConstant > > ,
10641073 ) -> UntypedConstant {
10651074 Constant :: Record {
10661075 location,
10671076 module,
10681077 name,
10691078 arguments,
1070- spread,
10711079 tag : ( ) ,
10721080 type_ : ( ) ,
10731081 field_map : None ,
10741082 record_constructor : None ,
10751083 }
10761084 }
10771085
1086+ fn fold_constant_record_update (
1087+ & mut self ,
1088+ location : SrcSpan ,
1089+ module : Option < ( EcoString , SrcSpan ) > ,
1090+ name : EcoString ,
1091+ record : Box < UntypedConstant > ,
1092+ arguments : Vec < ConstantRecordUpdateArg < UntypedConstant > > ,
1093+ ) -> UntypedConstant {
1094+ Constant :: RecordUpdate {
1095+ location,
1096+ module,
1097+ name,
1098+ record,
1099+ arguments,
1100+ tag : ( ) ,
1101+ type_ : ( ) ,
1102+ field_map : None ,
1103+ }
1104+ }
1105+
10781106 fn fold_constant_bit_array (
10791107 & mut self ,
10801108 location : SrcSpan ,
@@ -1149,7 +1177,6 @@ pub trait UntypedConstantFolder {
11491177 module,
11501178 name,
11511179 arguments,
1152- spread,
11531180 tag,
11541181 type_,
11551182 field_map,
@@ -1162,20 +1189,49 @@ pub trait UntypedConstantFolder {
11621189 argument
11631190 } )
11641191 . collect ( ) ;
1165- let spread = spread. map ( |s| Box :: new ( self . fold_constant ( * s) ) ) ;
11661192 Constant :: Record {
11671193 location,
11681194 module,
11691195 name,
11701196 arguments,
1171- spread,
11721197 tag,
11731198 type_,
11741199 field_map,
11751200 record_constructor,
11761201 }
11771202 }
11781203
1204+ Constant :: RecordUpdate {
1205+ location,
1206+ module,
1207+ name,
1208+ record,
1209+ arguments,
1210+ tag,
1211+ type_,
1212+ field_map,
1213+ } => {
1214+ let record = Box :: new ( self . fold_constant ( * record) ) ;
1215+ let arguments = arguments
1216+ . into_iter ( )
1217+ . map ( |arg| ConstantRecordUpdateArg {
1218+ label : arg. label ,
1219+ location : arg. location ,
1220+ value : self . fold_constant ( arg. value ) ,
1221+ } )
1222+ . collect ( ) ;
1223+ Constant :: RecordUpdate {
1224+ location,
1225+ module,
1226+ name,
1227+ record,
1228+ arguments,
1229+ tag,
1230+ type_,
1231+ field_map,
1232+ }
1233+ }
1234+
11791235 Constant :: BitArray { location, segments } => {
11801236 let segments = segments
11811237 . into_iter ( )
0 commit comments