rustc: Handle valueless ret expressions as block results. Closes #521
This commit is contained in:
parent
b4c3b83f26
commit
8746b84eec
@ -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;
|
||||
|
11
src/test/run-pass/expr-empty-ret.rs
Normal file
11
src/test/run-pass/expr-empty-ret.rs
Normal file
@ -0,0 +1,11 @@
|
||||
// xfail-stage0
|
||||
// Issue #521
|
||||
|
||||
fn f() {
|
||||
auto x = alt (true) {
|
||||
case (true) { 10 }
|
||||
case (false) { ret }
|
||||
};
|
||||
}
|
||||
|
||||
fn main() { }
|
Loading…
Reference in New Issue
Block a user