@@ -428,22 +428,22 @@ pub enum RuntimeCheck {
428
428
} ,
429
429
StringPrefix {
430
430
prefix : EcoString ,
431
- rest_arg : Variable ,
431
+ rest : Variable ,
432
432
} ,
433
433
Tuple {
434
434
size : usize ,
435
- args : Vec < Variable > ,
435
+ elements : Vec < Variable > ,
436
436
} ,
437
437
BitArray {
438
438
value : EcoString ,
439
439
} ,
440
440
Variant {
441
441
index : usize ,
442
- args : Vec < Variable > ,
442
+ fields : Vec < Variable > ,
443
443
} ,
444
444
NonEmptyList {
445
- first_arg : Variable ,
446
- rest_arg : Variable ,
445
+ first : Variable ,
446
+ rest : Variable ,
447
447
} ,
448
448
EmptyList ,
449
449
}
@@ -460,22 +460,18 @@ impl RuntimeCheck {
460
460
RuntimeCheck :: String { value } => RuntimeCheckKind :: String {
461
461
value : value. clone ( ) ,
462
462
} ,
463
- RuntimeCheck :: StringPrefix {
464
- prefix,
465
- rest_arg : _,
466
- } => RuntimeCheckKind :: StringPrefix {
463
+ RuntimeCheck :: StringPrefix { prefix, rest : _ } => RuntimeCheckKind :: StringPrefix {
467
464
prefix : prefix. clone ( ) ,
468
465
} ,
469
- RuntimeCheck :: Tuple { size, args : _ } => RuntimeCheckKind :: Tuple { size : * size } ,
466
+ RuntimeCheck :: Tuple { size, elements : _ } => RuntimeCheckKind :: Tuple { size : * size } ,
470
467
RuntimeCheck :: BitArray { value } => RuntimeCheckKind :: BitArray {
471
468
value : value. clone ( ) ,
472
469
} ,
473
- RuntimeCheck :: Variant { index, args : _ } => RuntimeCheckKind :: Variant { index : * index } ,
470
+ RuntimeCheck :: Variant { index, fields : _ } => {
471
+ RuntimeCheckKind :: Variant { index : * index }
472
+ }
474
473
RuntimeCheck :: EmptyList => RuntimeCheckKind :: EmptyList ,
475
- RuntimeCheck :: NonEmptyList {
476
- first_arg : _,
477
- rest_arg : _,
478
- } => RuntimeCheckKind :: NonEmptyList ,
474
+ RuntimeCheck :: NonEmptyList { first : _, rest : _ } => RuntimeCheckKind :: NonEmptyList ,
479
475
}
480
476
}
481
477
}
@@ -993,7 +989,7 @@ impl<'a> Compiler<'a> {
993
989
} ,
994
990
( RuntimeCheckKind :: StringPrefix { prefix } , _) => RuntimeCheck :: StringPrefix {
995
991
prefix : prefix. clone ( ) ,
996
- rest_arg : self . fresh_variable ( string ( ) ) ,
992
+ rest : self . fresh_variable ( string ( ) ) ,
997
993
} ,
998
994
( RuntimeCheckKind :: Tuple { .. } , BranchMode :: Tuple { elements } ) => {
999
995
self . is_tuple_check ( elements)
@@ -1047,32 +1043,47 @@ impl<'a> Compiler<'a> {
1047
1043
// After making sure a value is not an empty list we'll have to perform
1048
1044
// additional checks on its first item and on the tail.
1049
1045
(
1050
- Pattern :: NonEmptyList { first, rest } ,
1046
+ Pattern :: NonEmptyList {
1047
+ first : first_pattern,
1048
+ rest : rest_pattern,
1049
+ } ,
1051
1050
RuntimeCheck :: NonEmptyList {
1052
- first_arg ,
1053
- rest_arg ,
1051
+ first : first_variable ,
1052
+ rest : rest_variable ,
1054
1053
} ,
1055
- ) => vec ! [ first_arg. is( * first) , rest_arg. is( * rest) ] ,
1054
+ ) => vec ! [
1055
+ first_variable. is( * first_pattern) ,
1056
+ rest_variable. is( * rest_pattern) ,
1057
+ ] ,
1056
1058
1057
1059
// After making sure a value is a specific variant we'll have to check each
1058
1060
// of its arguments respects the given patterns (as shown in the doc example for
1059
1061
// this function!)
1060
- ( Pattern :: Variant { fields, .. } , RuntimeCheck :: Variant { args, .. } ) => {
1061
- ( args. iter ( ) . zip ( fields) )
1062
- . map ( |( arg, pattern) | arg. is ( * pattern) )
1063
- . collect_vec ( )
1064
- }
1062
+ (
1063
+ Pattern :: Variant {
1064
+ fields : patterns, ..
1065
+ } ,
1066
+ RuntimeCheck :: Variant {
1067
+ fields : variables, ..
1068
+ } ,
1069
+ ) => ( variables. iter ( ) . zip ( patterns) )
1070
+ . map ( |( field, pattern) | field. is ( * pattern) )
1071
+ . collect_vec ( ) ,
1065
1072
1066
1073
// Tuples are exactly the same as variants: after making sure we're dealing with
1067
1074
// a tuple, we will have to check that each of its elements matches the given
1068
1075
// pattern: `a is #(1, _)` will result in the following checks
1069
1076
// `a0 is 1, a1 is _` (where `a0` and `a1` are fresh variable names we use to
1070
1077
// refer to each of the tuple's elements).
1071
- ( Pattern :: Tuple { elements } , RuntimeCheck :: Tuple { args, .. } ) => {
1072
- ( args. iter ( ) . zip ( elements) )
1073
- . map ( |( arg, pattern) | arg. is ( * pattern) )
1074
- . collect_vec ( )
1075
- }
1078
+ (
1079
+ Pattern :: Tuple { elements : patterns } ,
1080
+ RuntimeCheck :: Tuple {
1081
+ elements : variables,
1082
+ ..
1083
+ } ,
1084
+ ) => ( variables. iter ( ) . zip ( patterns) )
1085
+ . map ( |( element, pattern) | element. is ( * pattern) )
1086
+ . collect_vec ( ) ,
1076
1087
1077
1088
// Strings are quite fun: if we've checked at runtime a string starts with a given
1078
1089
// prefix and we want to check that it's some overlapping literal value we'll still
@@ -1082,14 +1093,9 @@ impl<'a> Compiler<'a> {
1082
1093
// and we've just successfully ran the runtime check for `a is "wib" <> rest`.
1083
1094
// So we know the string already starts with `"wib"` what we have to check now
1084
1095
// is that the remaining part `rest` is `"ble"`.
1085
- (
1086
- Pattern :: String { value } ,
1087
- RuntimeCheck :: StringPrefix {
1088
- prefix, rest_arg, ..
1089
- } ,
1090
- ) => {
1096
+ ( Pattern :: String { value } , RuntimeCheck :: StringPrefix { prefix, rest, .. } ) => {
1091
1097
let remaining = value. strip_prefix ( prefix. as_str ( ) ) . unwrap_or ( value) ;
1092
- vec ! [ rest_arg . is( self . string_pattern( remaining) ) ]
1098
+ vec ! [ rest . is( self . string_pattern( remaining) ) ]
1093
1099
}
1094
1100
1095
1101
// String prefixes are similar to strings, but a bit more involved. Let's say we're
@@ -1120,7 +1126,7 @@ impl<'a> Compiler<'a> {
1120
1126
} ,
1121
1127
RuntimeCheck :: StringPrefix {
1122
1128
prefix : prefix0,
1123
- rest_arg : rest0,
1129
+ rest : rest0,
1124
1130
} ,
1125
1131
) => {
1126
1132
let remaining = prefix1. strip_prefix ( prefix0. as_str ( ) ) . unwrap_or ( prefix1) ;
@@ -1141,10 +1147,10 @@ impl<'a> Compiler<'a> {
1141
1147
) -> RuntimeCheck {
1142
1148
RuntimeCheck :: Variant {
1143
1149
index,
1144
- args : constructor
1150
+ fields : constructor
1145
1151
. parameters
1146
1152
. iter ( )
1147
- . map ( |p| p . type_ . clone ( ) )
1153
+ . map ( |parameter| parameter . type_ . clone ( ) )
1148
1154
. map ( |type_| self . fresh_variable ( type_) )
1149
1155
. collect_vec ( ) ,
1150
1156
}
@@ -1155,8 +1161,8 @@ impl<'a> Compiler<'a> {
1155
1161
///
1156
1162
fn is_list_check ( & mut self , inner_type : Arc < Type > ) -> RuntimeCheck {
1157
1163
RuntimeCheck :: NonEmptyList {
1158
- first_arg : self . fresh_variable ( inner_type. clone ( ) ) ,
1159
- rest_arg : self . fresh_variable ( Arc :: new ( Type :: list ( inner_type) ) ) ,
1164
+ first : self . fresh_variable ( inner_type. clone ( ) ) ,
1165
+ rest : self . fresh_variable ( Arc :: new ( Type :: list ( inner_type) ) ) ,
1160
1166
}
1161
1167
}
1162
1168
@@ -1166,7 +1172,7 @@ impl<'a> Compiler<'a> {
1166
1172
fn is_tuple_check ( & mut self , elements : & [ Arc < Type > ] ) -> RuntimeCheck {
1167
1173
RuntimeCheck :: Tuple {
1168
1174
size : elements. len ( ) ,
1169
- args : elements
1175
+ elements : elements
1170
1176
. iter ( )
1171
1177
. map ( |type_| self . fresh_variable ( type_. clone ( ) ) )
1172
1178
. collect_vec ( ) ,
0 commit comments