@@ -67,6 +67,7 @@ type fn_ctxt =
67
67
// (and with any functions whose environment is being captured).
68
68
{ ret_ty : ty:: t ,
69
69
purity : ast:: purity ,
70
+ proto : ast:: proto ,
70
71
var_bindings : @ty:: unify:: var_bindings ,
71
72
locals : hashmap[ ast:: node_id , int] ,
72
73
local_names : hashmap[ ast:: node_id , ast:: ident ] ,
@@ -1883,22 +1884,24 @@ fn check_expr(fcx: &@fn_ctxt, expr: &@ast::expr) -> bool {
1883
1884
}
1884
1885
ast:: expr_put ( expr_opt) {
1885
1886
require_impure ( tcx. sess , fcx. purity , expr. span ) ;
1887
+ if ( fcx. proto != ast:: proto_iter) {
1888
+ tcx. sess . span_fatal ( expr. span , "put in non-iterator" ) ;
1889
+ }
1886
1890
alt expr_opt {
1887
1891
none. {
1888
1892
let nil = ty:: mk_nil ( tcx) ;
1889
1893
if !are_compatible ( fcx, fcx. ret_ty , nil) {
1890
1894
tcx. sess . span_fatal ( expr. span ,
1891
1895
"put; in iterator yielding non-nil" ) ;
1892
1896
}
1893
- write:: nil_ty ( tcx, id) ;
1894
1897
}
1895
1898
some ( e) {
1896
1899
bot = check_expr ( fcx, e) ;
1897
1900
demand:: simple ( fcx, expr. span , fcx. ret_ty ,
1898
1901
expr_ty ( tcx, e) ) ;
1899
- write:: nil_ty ( tcx, id) ;
1900
1902
}
1901
1903
}
1904
+ write:: nil_ty ( tcx, id) ;
1902
1905
}
1903
1906
ast:: expr_be ( e) {
1904
1907
// FIXME: prove instead of assert
@@ -2619,12 +2622,12 @@ fn check_const(ccx: &@crate_ctxt, sp: &span, e: &@ast::expr,
2619
2622
id : & ast:: node_id ) {
2620
2623
// FIXME: this is kinda a kludge; we manufacture a fake function context
2621
2624
// and statement context for checking the initializer expression.
2622
-
2623
2625
let rty = node_id_to_type ( ccx. tcx , id) ;
2624
2626
let fixups: ast:: node_id [ ] = ~[ ] ;
2625
2627
let fcx: @fn_ctxt =
2626
2628
@{ ret_ty: rty,
2627
2629
purity: ast:: pure_fn,
2630
+ proto: ast:: proto_fn,
2628
2631
var_bindings: ty:: unify:: mk_var_bindings ( ) ,
2629
2632
locals: new_int_hash[ int] ( ) ,
2630
2633
local_names: new_int_hash[ ast:: ident] ( ) ,
@@ -2643,13 +2646,13 @@ fn check_fn(ccx: &@crate_ctxt, f: &ast::_fn, id: &ast::node_id,
2643
2646
let fcx: @fn_ctxt =
2644
2647
@{ ret_ty: ast_ty_to_ty_crate ( ccx, decl. output ) ,
2645
2648
purity: decl. purity ,
2649
+ proto: f. proto ,
2646
2650
var_bindings: gather_result. var_bindings ,
2647
2651
locals: gather_result. locals ,
2648
2652
local_names: gather_result. local_names ,
2649
2653
next_var_id: gather_result. next_var_id ,
2650
2654
mutable fixups: fixups,
2651
2655
ccx: ccx} ;
2652
-
2653
2656
check_block ( fcx, body) ;
2654
2657
alt decl. purity {
2655
2658
ast:: pure_fn. {
0 commit comments