@@ -1611,21 +1611,38 @@ fn check_expr_with_unifier(fcx: &@fn_ctxt, expr: &@ast::expr,
1611
1611
}
1612
1612
1613
1613
// Check the arguments.
1614
- let i = 0 u;
1615
- for a_opt: option:: t[ @ast:: expr] in args {
1616
- alt a_opt {
1617
- some( a) {
1618
- bot |= check_expr_with_unifier ( fcx, a, demand:: block_coerce,
1619
- arg_tys. ( i) . ty ) ;
1620
- }
1621
- none. { }
1614
+ // We do this in a pretty awful way: first we typecheck any arguments
1615
+ // that are not anonymous functions, then we typecheck the anonymous
1616
+ // functions. This is so that we have more information about the types
1617
+ // of arguments when we typecheck the functions. This isn't really the
1618
+ // right way to do this.
1619
+ let check_args = lambda ( check_blocks: bool ) -> bool {
1620
+ let i = 0 u;
1621
+ let bot = false ;
1622
+ for a_opt: option:: t[ @ast:: expr] in args {
1623
+ alt a_opt {
1624
+ some( a) {
1625
+ let is_block =
1626
+ alt a. node { ast:: expr_fn ( _) { true } _ { false } } ;
1627
+ if is_block == check_blocks {
1628
+ bot |= check_expr_with_unifier ( fcx, a,
1629
+ demand:: block_coerce,
1630
+ arg_tys. ( i) . ty ) ;
1631
+ }
1632
+ }
1633
+ none. { }
1634
+ }
1635
+ i += 1 u;
1622
1636
}
1623
- i += 1 u;
1624
- }
1637
+ ret bot;
1638
+ } ;
1639
+ bot |= check_args ( false ) ;
1640
+ bot |= check_args ( true ) ;
1641
+
1625
1642
ret bot;
1626
1643
}
1627
- // A generic function for checking assignment expressions
1628
1644
1645
+ // A generic function for checking assignment expressions
1629
1646
fn check_assignment ( fcx : & @fn_ctxt , sp : & span , lhs : & @ast:: expr ,
1630
1647
rhs : & @ast:: expr , id : & ast:: node_id ) -> bool {
1631
1648
let t = next_ty_var ( fcx) ;
0 commit comments