rustc: Handle valueless ret expressions as block results. Closes #521

This commit is contained in:
Brian Anderson 2011-06-22 17:16:17 -07:00
parent b4c3b83f26
commit 8746b84eec
2 changed files with 13 additions and 0 deletions

View File

@ -891,6 +891,8 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
} else if (eat_word(p, "ret")) {
alt (p.peek()) {
case (token::SEMI) { ex = ast::expr_ret(none); }
// Handle ret as the block result expression
case (token::RBRACE) { ex = ast::expr_ret(none); }
case (_) {
auto e = parse_expr(p);
hi = e.span.hi;

View File

@ -0,0 +1,11 @@
// xfail-stage0
// Issue #521
fn f() {
auto x = alt (true) {
case (true) { 10 }
case (false) { ret }
};
}
fn main() { }