提交 1e42c9a3 编写于 作者: N Niko Matsakis

Do not consider ty_bot to be a "resolved type".

Fixes #2149. Fixes #2150. Fixes #2151.
上级 7aaa120b
......@@ -232,8 +232,10 @@ fn instantiate_path(fcx: @fn_ctxt, pth: @ast::path,
// Type tests
fn structurally_resolved_type(fcx: @fn_ctxt, sp: span, tp: ty::t) -> ty::t {
alt infer::resolve_type_structure(fcx.infcx, tp) {
result::ok(typ_s) { ret typ_s; }
result::err(_) {
// note: the bot type doesn't count as resolved; it's what we use when
// there is no information about a variable.
result::ok(t_s) if !ty::type_is_bot(t_s) { ret t_s; }
_ {
fcx.ccx.tcx.sess.span_fatal
(sp, "the type of this value must be known in this context");
}
......
iface monad<A> {
fn bind<B>(fn(A) -> self<B>);
}
impl monad<A> of monad<A> for [A] {
fn bind<B>(f: fn(A) -> [B]) {
let mut r = fail;
for self.each {|elt| r += f(elt); }
//!^ WARNING unreachable expression
//!^^ ERROR the type of this value must be known
}
}
fn main() {
["hi"].bind {|x| [x] };
}
\ No newline at end of file
fn fail_len(v: [const int]) -> uint {
let mut i = fail;
for v.each {|x| i += 1u; }
//!^ WARNING unreachable statement
//!^^ ERROR the type of this value must be known
ret i;
}
fn main() {}
\ No newline at end of file
fn main() {
vec::iter(fail) {|i|
log (debug, i * 2);
//!^ ERROR the type of this value must be known
};
}
\ No newline at end of file
// xfail-pretty
fn id(x: bool) -> bool { x }
fn call_id() {
let c <- fail;
id(c); //! WARNING unreachable statement
}
fn call_id_3() { id(ret) && id(ret); }
//!^ ERROR the type of this value must be known
fn main() {
}
......@@ -4,5 +4,7 @@
// preserved. They are needed to disambiguate `{ret n+1}; - 0` from
// `({ret n+1}-0)`.
fn wsucc(n: int) -> int { ({ ret n + 1 }) - 0; }
fn id(f: fn() -> int) -> int { f() }
fn wsucc(n: int) -> int { (id {|| 1 }) - 0 }
fn main() { }
fn wsucc(n: int) -> int { ({ ret n + 1 } + 0); }
fn wsucc(n: int) -> int { 0 + { ret n + 1 } }
fn main() { }
......@@ -9,8 +9,6 @@ fn call_id() {
fn call_id_2() { id(true) && id(ret); }
fn call_id_3() { id(ret) && id(ret); }
fn call_id_4() { while id(ret) { } }
fn bind_id_1() { bind id(fail); }
......@@ -27,7 +25,7 @@ fn call_id_4() { while id(ret) { } }
fn log_cont() { do { log(error, cont); } while false }
fn ret_ret() -> int { ret (ret 2) + 3; }
fn ret_ret() -> int { ret 3 + (ret 2); }
fn ret_guard() {
alt check 2 {
......@@ -53,7 +51,6 @@ fn main() {
ret_ret();
log_ret();
call_id_2();
call_id_3();
call_id_4();
bind_id_2();
ret_guard();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册