@@ -1549,10 +1549,10 @@ impl Parser {
15491549 } else if self . eat_keyword ( keywords:: If ) {
15501550 return self . parse_if_expr ( ) ;
15511551 } else if self . eat_keyword ( keywords:: For ) {
1552- return self . parse_sugary_call_expr ( ~"for ", ForSugar,
1552+ return self . parse_sugary_call_expr ( lo , ~"for ", ForSugar,
15531553 expr_loop_body);
15541554 } else if self.eat_keyword(keywords::Do) {
1555- return self.parse_sugary_call_expr(~" do", DoSugar ,
1555+ return self.parse_sugary_call_expr(lo, ~" do", DoSugar ,
15561556 expr_do_body) ;
15571557 } else if self . eat_keyword ( keywords:: While ) {
15581558 return self . parse_while_expr ( ) ;
@@ -2264,12 +2264,11 @@ impl Parser {
22642264 // parse a 'for' or 'do'.
22652265 // the 'for' and 'do' expressions parse as calls, but look like
22662266 // function calls followed by a closure expression.
2267- pub fn parse_sugary_call_expr ( & self ,
2267+ pub fn parse_sugary_call_expr ( & self , lo : BytePos ,
22682268 keyword : ~str ,
22692269 sugar : CallSugar ,
22702270 ctor : & fn ( v: @expr) -> expr_ )
22712271 -> @expr {
2272- let lo = self . last_span ;
22732272 // Parse the callee `foo` in
22742273 // for foo || {
22752274 // for foo.bar || {
@@ -2286,21 +2285,21 @@ impl Parser {
22862285 let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
22872286 ctor ( block) ) ;
22882287 let args = vec:: append ( copy * args, [ last_arg] ) ;
2289- self . mk_expr ( lo. lo , block. span . hi , expr_call ( f, args, sugar) )
2288+ self . mk_expr ( lo, block. span . hi , expr_call ( f, args, sugar) )
22902289 }
22912290 expr_method_call( _, f, i, ref tps, ref args, NoSugar ) => {
22922291 let block = self . parse_lambda_block_expr ( ) ;
22932292 let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
22942293 ctor ( block) ) ;
22952294 let args = vec:: append ( copy * args, [ last_arg] ) ;
2296- self . mk_expr ( lo. lo , block. span . hi ,
2295+ self . mk_expr ( lo, block. span . hi ,
22972296 self . mk_method_call ( f, i, copy * tps, args, sugar) )
22982297 }
22992298 expr_field( f, i, ref tps) => {
23002299 let block = self . parse_lambda_block_expr ( ) ;
23012300 let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
23022301 ctor ( block) ) ;
2303- self . mk_expr ( lo. lo , block. span . hi ,
2302+ self . mk_expr ( lo, block. span . hi ,
23042303 self . mk_method_call ( f, i, copy * tps, ~[ last_arg] , sugar) )
23052304 }
23062305 expr_path( * ) | expr_call( * ) | expr_method_call( * ) |
@@ -2309,7 +2308,7 @@ impl Parser {
23092308 let last_arg = self . mk_expr ( block. span . lo , block. span . hi ,
23102309 ctor ( block) ) ;
23112310 self . mk_expr (
2312- lo. lo ,
2311+ lo,
23132312 last_arg. span . hi ,
23142313 self . mk_call ( e, ~[ last_arg] , sugar) )
23152314 }
@@ -2319,7 +2318,7 @@ impl Parser {
23192318 // but they aren't represented by tests
23202319 debug ! ( "sugary call on %?" , e. node) ;
23212320 self . span_fatal (
2322- * lo ,
2321+ e . span ,
23232322 fmt ! ( "`%s` must be followed by a block call" , keyword) ) ;
23242323 }
23252324 }
0 commit comments