Cleanup for 'be' statement and comments about future typestate
This commit is contained in:
parent
6461cf30de
commit
f17a3421e0
@ -315,6 +315,17 @@ fn index_native_item(native_mod_index index, @native_item it) {
|
||||
}
|
||||
}
|
||||
|
||||
fn is_call_expr(@expr e) -> bool {
|
||||
alt (e.node) {
|
||||
case (expr_call(_, _, _)) {
|
||||
ret true;
|
||||
}
|
||||
case (_) {
|
||||
ret false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Local Variables:
|
||||
// mode: rust
|
||||
|
@ -1203,7 +1203,13 @@ impure fn parse_stmt(parser p) -> @ast.stmt {
|
||||
case (token.BE) {
|
||||
p.bump();
|
||||
auto e = parse_expr(p);
|
||||
ret @spanned(lo, e.span, ast.stmt_be(e));
|
||||
// FIXME: Is this the right place for this check?
|
||||
if /*check*/ (ast.is_call_expr(e)) {
|
||||
ret @spanned(lo, e.span, ast.stmt_be(e));
|
||||
}
|
||||
else {
|
||||
p.err("Non-call expression in tail call");
|
||||
}
|
||||
}
|
||||
|
||||
case (token.LET) {
|
||||
|
@ -3129,7 +3129,10 @@ fn trans_ret(@block_ctxt cx, &option.t[@ast.expr] e) -> result {
|
||||
}
|
||||
|
||||
fn trans_be(@block_ctxt cx, @ast.expr e) -> result {
|
||||
// FIXME: So this isn't actually a tail call
|
||||
// FIXME: This should be a typestate precondition
|
||||
check ast.is_call_expr(e);
|
||||
// FIXME: Turn this into a real tail call once
|
||||
// calling convention issues are settled
|
||||
ret trans_ret(cx, some(e));
|
||||
}
|
||||
|
||||
|
@ -1720,18 +1720,12 @@ fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
|
||||
}
|
||||
|
||||
case (ast.stmt_be(?expr)) {
|
||||
alt (expr.node) {
|
||||
case (ast.expr_call(_, _, _)) {
|
||||
auto expr_0 = check_expr(fcx, expr);
|
||||
auto expr_1 = demand_expr(fcx, fcx.ret_ty, expr_0);
|
||||
ret @fold.respan[ast.stmt_](stmt.span,
|
||||
ast.stmt_be(expr_1));
|
||||
}
|
||||
case (_) {
|
||||
fcx.ccx.sess.err("Non-call expression in tail call");
|
||||
fail;
|
||||
}
|
||||
}
|
||||
/* FIXME: prove instead of check */
|
||||
check ast.is_call_expr(expr);
|
||||
auto expr_0 = check_expr(fcx, expr);
|
||||
auto expr_1 = demand_expr(fcx, fcx.ret_ty, expr_0);
|
||||
ret @fold.respan[ast.stmt_](stmt.span,
|
||||
ast.stmt_be(expr_1));
|
||||
}
|
||||
|
||||
case (ast.stmt_log(?expr)) {
|
||||
|
@ -7,4 +7,4 @@ fn f() -> int {
|
||||
|
||||
fn main() {
|
||||
auto y = f();
|
||||
}
|
||||
}
|
||||
|
@ -10,4 +10,4 @@ fn g() -> uint {
|
||||
|
||||
fn main() {
|
||||
auto y = f();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user