@@ -26,7 +26,6 @@ use std::sync::Arc;
26
26
27
27
use scoped_arena:: Scope ;
28
28
29
- use super :: ExprField ;
30
29
use crate :: alloc:: SliceVec ;
31
30
use crate :: core:: semantics:: { self , ArcValue , Head , Telescope , Value } ;
32
31
use crate :: core:: { self , prim, Const , Plicity , Prim , UIntStyle } ;
@@ -668,7 +667,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
668
667
expected : to,
669
668
error,
670
669
} ) ;
671
- core:: Term :: Prim ( span, Prim :: ReportedError )
670
+ core:: Term :: error ( span)
672
671
}
673
672
} ,
674
673
}
@@ -1052,7 +1051,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1052
1051
. check_record_fields ( * range, expr_fields, |field| field. label , labels)
1053
1052
. is_err ( )
1054
1053
{
1055
- return core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ;
1054
+ return core:: Term :: error ( file_range) ;
1056
1055
}
1057
1056
1058
1057
let mut types = types. clone ( ) ;
@@ -1119,7 +1118,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1119
1118
. check_tuple_fields ( * range, elem_exprs, |term| term. range ( ) , labels)
1120
1119
. is_err ( )
1121
1120
{
1122
- return core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ;
1121
+ return core:: Term :: error ( file_range) ;
1123
1122
}
1124
1123
1125
1124
let mut types = types. clone ( ) ;
@@ -1153,16 +1152,14 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1153
1152
Some ( ( Prim :: Array64Type , [ App ( _, len) , App ( _, elem_type) ] ) ) => {
1154
1153
( Some ( len) , elem_type)
1155
1154
}
1156
- Some ( ( Prim :: ReportedError , _) ) => {
1157
- return core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError )
1158
- }
1155
+ Some ( ( Prim :: ReportedError , _) ) => return core:: Term :: error ( file_range) ,
1159
1156
_ => {
1160
1157
let expected_type = self . pretty_print_value ( & expected_type) ;
1161
1158
self . push_message ( Message :: ArrayLiteralNotSupported {
1162
1159
range : file_range,
1163
1160
expected_type,
1164
1161
} ) ;
1165
- return core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ;
1162
+ return core:: Term :: error ( file_range) ;
1166
1163
}
1167
1164
} ;
1168
1165
@@ -1173,7 +1170,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1173
1170
Some ( Value :: ConstLit ( Const :: U32 ( len, _) ) ) => Some ( * len as u64 ) ,
1174
1171
Some ( Value :: ConstLit ( Const :: U64 ( len, _) ) ) => Some ( * len) ,
1175
1172
Some ( Value :: Stuck ( Head :: Prim ( Prim :: ReportedError ) , _) ) => {
1176
- return core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ;
1173
+ return core:: Term :: error ( file_range)
1177
1174
}
1178
1175
_ => None ,
1179
1176
} ;
@@ -1199,7 +1196,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1199
1196
expected_len,
1200
1197
} ) ;
1201
1198
1202
- core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError )
1199
+ return core:: Term :: error ( file_range) ;
1203
1200
}
1204
1201
}
1205
1202
}
@@ -1226,7 +1223,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1226
1223
1227
1224
match constant {
1228
1225
Some ( constant) => core:: Term :: ConstLit ( file_range. into ( ) , constant) ,
1229
- None => core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ,
1226
+ None => core:: Term :: error ( file_range) ,
1230
1227
}
1231
1228
}
1232
1229
( Term :: NumberLiteral ( range, lit) , _) => {
@@ -1248,19 +1245,19 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1248
1245
range : file_range,
1249
1246
expected_type,
1250
1247
} ) ;
1251
- return core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ;
1248
+ return core:: Term :: error ( file_range) ;
1252
1249
}
1253
1250
} ;
1254
1251
1255
1252
match constant {
1256
1253
Some ( constant) => core:: Term :: ConstLit ( file_range. into ( ) , constant) ,
1257
- None => core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ,
1254
+ None => core:: Term :: error ( file_range) ,
1258
1255
}
1259
1256
}
1260
1257
( Term :: BinOp ( range, lhs, op, rhs) , _) => {
1261
1258
self . check_bin_op ( * range, lhs, * op, rhs, & expected_type)
1262
1259
}
1263
- ( Term :: ReportedError ( _) , _) => core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ,
1260
+ ( Term :: ReportedError ( _) , _) => core:: Term :: error ( file_range) ,
1264
1261
( _, _) => {
1265
1262
let surface_range = surface_term. range ( ) ;
1266
1263
let ( synth_term, synth_type) = self . synth ( surface_term) ;
@@ -1633,9 +1630,8 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1633
1630
// There's been an error when elaborating the head of
1634
1631
// the projection, so avoid trying to elaborate any
1635
1632
// further to prevent cascading type errors.
1636
- ( core:: Term :: Prim ( _, Prim :: ReportedError ) , _)
1637
- | ( _, Value :: Stuck ( Head :: Prim ( Prim :: ReportedError ) , _) ) => {
1638
- return self . synth_reported_error ( * range) ;
1633
+ ( expr, r#type) if expr. is_error ( ) || r#type. is_error ( ) => {
1634
+ return self . synth_reported_error ( * range)
1639
1635
}
1640
1636
// The head expression was not a record type.
1641
1637
// Fallthrough with an error.
@@ -1774,7 +1770,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1774
1770
self . coerce ( range, expr, & type_value, expected_type)
1775
1771
}
1776
1772
Value :: Stuck ( Head :: Prim ( Prim :: ReportedError ) , _) => {
1777
- core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError )
1773
+ core:: Term :: error ( file_range)
1778
1774
}
1779
1775
_ => {
1780
1776
self . push_message ( Message :: UnexpectedParameter {
@@ -1783,7 +1779,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
1783
1779
// TODO: For improved error recovery, bind the rest of
1784
1780
// the parameters, and check the body of the function
1785
1781
// literal using the expected body type.
1786
- core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError )
1782
+ core:: Term :: error ( file_range)
1787
1783
}
1788
1784
}
1789
1785
}
@@ -2091,7 +2087,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
2091
2087
2092
2088
fn synth_reported_error ( & mut self , range : ByteRange ) -> ( core:: Term < ' arena > , ArcValue < ' arena > ) {
2093
2089
let file_range = self . file_range ( range) ;
2094
- let expr = core:: Term :: Prim ( file_range. into ( ) , Prim :: ReportedError ) ;
2090
+ let expr = core:: Term :: error ( file_range) ;
2095
2091
let r#type = self . push_unsolved_type ( MetaSource :: ReportedErrorType ( file_range) ) ;
2096
2092
( expr, r#type)
2097
2093
}
@@ -2353,7 +2349,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
2353
2349
CheckedPattern :: ReportedError ( range) => {
2354
2350
self . check ( body_expr, & match_info. expected_type ) ;
2355
2351
self . elab_match_unreachable ( match_info, equations) ;
2356
- core:: Term :: Prim ( range. into ( ) , Prim :: ReportedError )
2352
+ core:: Term :: error ( range)
2357
2353
}
2358
2354
}
2359
2355
}
@@ -2440,7 +2436,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
2440
2436
}
2441
2437
CheckedPattern :: ReportedError ( range) => {
2442
2438
( self . local_env ) . push_param ( None , match_info. scrutinee . r#type . clone ( ) ) ;
2443
- let default_expr = core:: Term :: Prim ( range. into ( ) , Prim :: ReportedError ) ;
2439
+ let default_expr = core:: Term :: error ( range) ;
2444
2440
default_branch = ( None , self . scope . to_scope ( default_expr) as & _ ) ;
2445
2441
self . local_env . pop ( ) ;
2446
2442
}
@@ -2498,10 +2494,7 @@ impl<'interner, 'arena> Context<'interner, 'arena> {
2498
2494
scrutinee_expr_range : self . file_range ( match_info. scrutinee . range ) ,
2499
2495
} ) ;
2500
2496
}
2501
- core:: Term :: Prim (
2502
- self . file_range ( match_info. range ) . into ( ) ,
2503
- Prim :: ReportedError ,
2504
- )
2497
+ core:: Term :: error ( self . file_range ( match_info. range ) )
2505
2498
}
2506
2499
}
2507
2500
0 commit comments