Skip to content

Commit dea90da

Browse files
jdmbrson
authored andcommitted
---
yaml --- r: 3561 b: refs/heads/master c: a2775a5 h: refs/heads/master i: 3559: e4f1df7 v: v3
1 parent 34da576 commit dea90da

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b110bbf886fd2d9d99c6e66b084ebd2430c57fe3
2+
refs/heads/master: a2775a5b72b7cad1bfe2a480a79bfe48281dd40f

trunk/src/comp/middle/trans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6388,9 +6388,9 @@ fn trans_fail_expr(&@block_ctxt cx, &option::t[common::span] sp_opt,
63886388
[C_int(0), C_int(abi::vec_elt_data)]);
63896389
ret trans_fail_value(bcx, sp_opt, elt);
63906390
} else {
6391-
bcx.fcx.lcx.ccx.sess.span_fatal(expr.span,
6392-
"fail called with unsupported \
6393-
type " + ty_to_str(tcx, e_ty));
6391+
cx.fcx.lcx.ccx.sess.span_bug(expr.span,
6392+
"fail called with unsupported \
6393+
type " + ty_to_str(tcx, e_ty));
63946394
}
63956395
}
63966396
case (_) {

trunk/src/comp/middle/typeck.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,11 @@ fn type_is_scalar(&@fn_ctxt fcx, &span sp, ty::t typ) -> bool {
229229
ret ty::type_is_scalar(fcx.ccx.tcx, typ_s);
230230
}
231231

232+
fn type_is_str(&@fn_ctxt fcx, &span sp, ty::t typ) -> bool {
233+
auto typ_s = structurally_resolved_type(fcx, sp, typ);
234+
ret ty::type_is_str(fcx.ccx.tcx, typ_s);
235+
}
236+
232237

233238
// Parses the programmer's textual representation of a type into our internal
234239
// notion of a type. `getter` is a function that returns the type
@@ -1658,7 +1663,17 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
16581663
case (ast::expr_fail(?expr_opt)) {
16591664
alt (expr_opt) {
16601665
case (none) { /* do nothing */ }
1661-
case (some(?e)) { check_expr(fcx, e); }
1666+
case (some(?e)) {
1667+
check_expr(fcx, e);
1668+
auto tcx = fcx.ccx.tcx;
1669+
auto ety = expr_ty(tcx, e);
1670+
if (!type_is_str(fcx, e.span, ety)) {
1671+
tcx.sess.span_fatal(e.span,
1672+
#fmt("mismatched types: expected \
1673+
str, found %s",
1674+
ty_to_str(tcx, ety)));
1675+
}
1676+
}
16621677
}
16631678
write::bot_ty(fcx.ccx.tcx, id);
16641679
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// error-pattern:mismatched types
2+
3+
fn main() {
4+
fail 5;
5+
}

0 commit comments

Comments
 (0)