@@ -7,7 +7,6 @@ import middle::fold;
7
7
import driver:: session;
8
8
import util:: common;
9
9
import util:: common:: span;
10
- import util:: common:: plain_ann;
11
10
import util:: common:: new_def_hash;
12
11
import util:: common:: log_expr_err;
13
12
@@ -25,6 +24,7 @@ import middle::ty::mo_either;
25
24
import middle:: ty:: node_type_table;
26
25
import middle:: ty:: pat_ty;
27
26
import middle:: ty:: path_to_str;
27
+ import middle:: ty:: plain_ann;
28
28
import middle:: ty:: struct;
29
29
import middle:: ty:: triv_ann;
30
30
import middle:: ty:: ty_param_substs_opt_and_ty;
@@ -387,6 +387,11 @@ fn write_type_only(&node_type_table ntt, uint node_id, ty::t ty) {
387
387
be write_type( ntt, node_id, tup( none[ vec[ ty:: t] ] , ty) ) ;
388
388
}
389
389
390
+ // Writes a nil type into the node type table.
391
+ fn write_nil_type( ty:: ctxt tcx, & node_type_table ntt, uint node_id) {
392
+ be write_type_only( ntt, node_id, ty:: mk_nil( tcx) ) ;
393
+ }
394
+
390
395
391
396
// Item collection - a pair of bootstrap passes:
392
397
//
@@ -1631,15 +1636,20 @@ mod Pushdown {
1631
1636
auto e_1 = pushdown_expr( fcx, expected, e_0) ;
1632
1637
auto block_ = rec( stmts=bloc. node. stmts,
1633
1638
expr=some[ @ast:: expr] ( e_1) ,
1634
- a=plain_ann( bloc. node. a, fcx. ccx. tcx) ) ;
1639
+ a=plain_ann( ast:: ann_tag( bloc. node. a) ,
1640
+ fcx. ccx. tcx) ) ;
1641
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
1642
+ ast:: ann_tag( bloc. node. a) ) ;
1635
1643
ret fold:: respan[ ast:: block_] ( bloc. span, block_) ;
1636
1644
}
1637
1645
case ( none[ @ast:: expr] ) {
1638
1646
Demand :: simple( fcx, bloc. span, expected,
1639
1647
ty:: mk_nil( fcx. ccx. tcx) ) ;
1640
- ret fold:: respan( bloc. span,
1641
- rec( a = plain_ann( bloc. node. a, fcx. ccx. tcx)
1642
- with bloc. node) ) ;
1648
+ auto new_ann = plain_ann( ast:: ann_tag( bloc. node. a) ,
1649
+ fcx. ccx. tcx) ;
1650
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
1651
+ ast:: ann_tag( bloc. node. a) ) ;
1652
+ ret fold:: respan( bloc. span, rec( a=new_ann with bloc. node) ) ;
1643
1653
1644
1654
}
1645
1655
}
@@ -2158,21 +2168,29 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2158
2168
}
2159
2169
2160
2170
case ( ast:: expr_fail( ?a) ) {
2161
- ret @fold:: respan[ ast:: expr_] ( expr. span,
2162
- ast:: expr_fail( plain_ann( a, fcx. ccx. tcx) ) ) ;
2171
+ // TODO: should be something like 'a or noret
2172
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2173
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
2174
+ ret @fold:: respan[ ast:: expr_] ( expr. span, ast:: expr_fail( new_ann) ) ;
2163
2175
}
2164
2176
2165
2177
case ( ast:: expr_break( ?a) ) {
2178
+ // TODO: should be something like 'a or noret
2179
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2180
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
2166
2181
ret @fold:: respan[ ast:: expr_] ( expr. span,
2167
- ast:: expr_break( plain_ann ( a , fcx . ccx . tcx ) ) ) ;
2182
+ ast:: expr_break( new_ann ) ) ;
2168
2183
}
2169
2184
2170
2185
case ( ast:: expr_cont( ?a) ) {
2171
- ret @fold:: respan[ ast:: expr_] ( expr. span,
2172
- ast:: expr_cont( plain_ann( a, fcx. ccx. tcx) ) ) ;
2186
+ // TODO: should be something like 'a or noret
2187
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2188
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
2189
+ ret @fold:: respan[ ast:: expr_] ( expr. span, ast:: expr_cont( new_ann) ) ;
2173
2190
}
2174
2191
2175
2192
case ( ast:: expr_ret( ?expr_opt, ?a) ) {
2193
+ // TODO: should be something like 'a or noret
2176
2194
alt ( expr_opt) {
2177
2195
case ( none[ @ast:: expr] ) {
2178
2196
auto nil = ty:: mk_nil( fcx. ccx. tcx) ;
@@ -2181,19 +2199,26 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2181
2199
+ "returning non-nil" ) ;
2182
2200
}
2183
2201
2202
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2203
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
2204
+ ast:: ann_tag( a) ) ;
2205
+
2184
2206
ret @fold:: respan[ ast:: expr_]
2185
2207
( expr. span,
2186
- ast:: expr_ret( none[ @ast:: expr] ,
2187
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2208
+ ast:: expr_ret( none[ @ast:: expr] , new_ann) ) ;
2188
2209
}
2189
2210
2190
2211
case ( some[ @ast:: expr] ( ?e) ) {
2191
2212
auto expr_0 = check_expr( fcx, e) ;
2192
2213
auto expr_1 = Pushdown :: pushdown_expr( fcx, fcx. ret_ty,
2193
2214
expr_0) ;
2215
+
2216
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2217
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
2218
+ ast:: ann_tag( a) ) ;
2219
+
2194
2220
ret @fold:: respan[ ast:: expr_]
2195
- ( expr. span, ast:: expr_ret( some( expr_1) ,
2196
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2221
+ ( expr. span, ast:: expr_ret( some( expr_1) , new_ann) ) ;
2197
2222
}
2198
2223
}
2199
2224
}
@@ -2209,18 +2234,25 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2209
2234
+ "putting non-nil" ) ;
2210
2235
}
2211
2236
2237
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2238
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
2239
+ ast:: ann_tag( a) ) ;
2240
+
2212
2241
ret @fold:: respan[ ast:: expr_]
2213
- ( expr. span, ast:: expr_put( none[ @ast:: expr] ,
2214
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2242
+ ( expr. span, ast:: expr_put( none[ @ast:: expr] , new_ann) ) ;
2215
2243
}
2216
2244
2217
2245
case ( some[ @ast:: expr] ( ?e) ) {
2218
2246
auto expr_0 = check_expr( fcx, e) ;
2219
2247
auto expr_1 = Pushdown :: pushdown_expr( fcx, fcx. ret_ty,
2220
2248
expr_0) ;
2249
+
2250
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2251
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
2252
+ ast:: ann_tag( a) ) ;
2253
+
2221
2254
ret @fold:: respan[ ast:: expr_]
2222
- ( expr. span, ast:: expr_put( some( expr_1) ,
2223
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2255
+ ( expr. span, ast:: expr_put( some( expr_1) , new_ann) ) ;
2224
2256
}
2225
2257
}
2226
2258
}
@@ -2230,15 +2262,21 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2230
2262
assert ( ast:: is_call_expr( e) ) ;
2231
2263
auto expr_0 = check_expr( fcx, e) ;
2232
2264
auto expr_1 = Pushdown :: pushdown_expr( fcx, fcx. ret_ty, expr_0) ;
2233
- ret @fold:: respan( expr. span,
2234
- ast:: expr_be( expr_1, plain_ann( a, fcx. ccx. tcx) ) ) ;
2265
+
2266
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2267
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
2268
+
2269
+ ret @fold:: respan( expr. span, ast:: expr_be( expr_1, new_ann) ) ;
2235
2270
}
2236
2271
2237
2272
case ( ast:: expr_log( ?l, ?e, ?a) ) {
2238
2273
auto expr_t = check_expr( fcx, e) ;
2239
- ret @fold:: respan[ ast:: expr_]
2240
- ( expr. span, ast:: expr_log( l, expr_t,
2241
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2274
+
2275
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2276
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
2277
+
2278
+ ret @fold:: respan[ ast:: expr_] ( expr. span,
2279
+ ast:: expr_log( l, expr_t, new_ann) ) ;
2242
2280
}
2243
2281
2244
2282
case ( ast:: expr_check( ?e, ?a) ) {
@@ -2265,9 +2303,13 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2265
2303
2266
2304
require_pure_function( fcx. ccx, d_id, expr. span) ;
2267
2305
2306
+ auto new_ann = plain_ann( ast:: ann_tag( a) ,
2307
+ fcx. ccx. tcx) ;
2308
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
2309
+ ast:: ann_tag( a) ) ;
2310
+
2268
2311
ret @fold:: respan[ ast:: expr_]
2269
- ( expr. span, ast:: expr_check( expr_t,
2270
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2312
+ ( expr. span, ast:: expr_check( expr_t, new_ann) ) ;
2271
2313
}
2272
2314
case ( _) {
2273
2315
fcx. ccx. sess. span_err( expr. span,
@@ -2287,9 +2329,12 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr {
2287
2329
auto expr_t = check_expr( fcx, e) ;
2288
2330
Demand :: simple( fcx, expr. span, ty:: mk_bool( fcx. ccx. tcx) ,
2289
2331
expr_ty( fcx. ccx. tcx, fcx. ccx. node_types, expr_t) ) ;
2290
- ret @fold:: respan[ ast:: expr_]
2291
- ( expr. span, ast:: expr_assert( expr_t,
2292
- plain_ann( a, fcx. ccx. tcx) ) ) ;
2332
+
2333
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
2334
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
2335
+
2336
+ ret @fold:: respan[ ast:: expr_] ( expr. span,
2337
+ ast:: expr_assert( expr_t, new_ann) ) ;
2293
2338
}
2294
2339
2295
2340
case ( ast:: expr_assign( ?lhs, ?rhs, ?a) ) {
@@ -3033,16 +3078,23 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
3033
3078
alt ( decl. node) {
3034
3079
case ( ast:: decl_local( _) ) {
3035
3080
auto decl_1 = check_decl_local( fcx, decl) ;
3081
+
3082
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
3083
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
3084
+ ast:: ann_tag( a) ) ;
3085
+
3036
3086
ret @fold:: respan[ ast:: stmt_] ( stmt. span,
3037
- ast:: stmt_decl( decl_1,
3038
- plain_ann( a, fcx. ccx. tcx) ) ) ;
3087
+ ast:: stmt_decl( decl_1, new_ann) ) ;
3039
3088
}
3040
3089
3041
3090
case ( ast:: decl_item( _) ) {
3042
3091
// Ignore for now. We'll return later.
3092
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
3093
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
3094
+ ast:: ann_tag( a) ) ;
3095
+
3043
3096
ret @fold:: respan[ ast:: stmt_] ( stmt. span,
3044
- ast:: stmt_decl( decl,
3045
- plain_ann( a, fcx. ccx. tcx) ) ) ;
3097
+ ast:: stmt_decl( decl, new_ann) ) ;
3046
3098
}
3047
3099
}
3048
3100
@@ -3053,9 +3105,11 @@ fn check_stmt(&@fn_ctxt fcx, &@ast::stmt stmt) -> @ast::stmt {
3053
3105
auto expr_t = check_expr( fcx, expr) ;
3054
3106
expr_t = Pushdown :: pushdown_expr( fcx,
3055
3107
expr_ty( fcx. ccx. tcx, fcx. ccx. node_types, expr_t) , expr_t) ;
3056
- ret @fold:: respan( stmt. span,
3057
- ast:: stmt_expr( expr_t,
3058
- plain_ann( a, fcx. ccx. tcx) ) ) ;
3108
+
3109
+ auto new_ann = plain_ann( ast:: ann_tag( a) , fcx. ccx. tcx) ;
3110
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types, ast:: ann_tag( a) ) ;
3111
+
3112
+ ret @fold:: respan( stmt. span, ast:: stmt_expr( expr_t, new_ann) ) ;
3059
3113
}
3060
3114
}
3061
3115
@@ -3079,9 +3133,11 @@ fn check_block(&@fn_ctxt fcx, &ast::block block) -> ast::block {
3079
3133
}
3080
3134
}
3081
3135
3082
- ret fold:: respan( block. span,
3083
- rec( stmts=stmts, expr=expr,
3084
- a=plain_ann( block. node. a, fcx. ccx. tcx) ) ) ;
3136
+ auto new_ann = plain_ann( ast:: ann_tag( block. node. a) , fcx. ccx. tcx) ;
3137
+ write_nil_type( fcx. ccx. tcx, fcx. ccx. node_types,
3138
+ ast:: ann_tag( block. node. a) ) ;
3139
+
3140
+ ret fold:: respan( block. span, rec( stmts=stmts, expr=expr, a=new_ann) ) ;
3085
3141
}
3086
3142
3087
3143
fn check_const( & @crate_ctxt ccx, & span sp, & ast:: ident ident, & @ast:: ty t,
0 commit comments