diff options
| -rw-r--r-- | src/comp/middle/typeck.rs | 11 | ||||
| -rw-r--r-- | src/test/compile-fail/pred-not-bool.rs | 4 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 4cea077ff49..68c12842f0a 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -2841,6 +2841,17 @@ fn check_fn(&@crate_ctxt ccx, &ast.fn_decl decl, ast.proto proto, // TODO: Make sure the type of the block agrees with the function type. auto block_t = check_block(fcx, body); + alt (decl.purity) { + case (ast.pure_fn) { + // per the previous comment, this just checks that the declared + // type is bool, and trusts that that's the actual return type. + if (!ty.type_is_bool(ccx.tcx, fcx.ret_ty)) { + ccx.sess.span_err(body.span, "Non-boolean return type in pred"); + } + } + case (_) {} + } + auto block_wb = resolve_local_types_in_block(fcx, block_t); auto fn_t = rec(decl=decl, diff --git a/src/test/compile-fail/pred-not-bool.rs b/src/test/compile-fail/pred-not-bool.rs index c0d19ef2c9f..7c7fa3d1759 100644 --- a/src/test/compile-fail/pred-not-bool.rs +++ b/src/test/compile-fail/pred-not-bool.rs @@ -1,6 +1,8 @@ // -*- rust -*- +// xfail-boot +// xfail-stage0 -// error-pattern: mismatched types +// error-pattern: Non-boolean return type // this checks that a pred with a non-bool return // type is rejected, even if the pred is never used |
