Skip to content

Commit ee855ca

Browse files
committed
Don't ICE when protocol steps to invalid mesasge.
1 parent 4cf6b4d commit ee855ca

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

src/libsyntax/ext/pipes/check.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,29 @@ impl proto_check of proto::visitor<(), (), ()> for ext_ctxt {
4444

4545
fn visit_message(name: ident, _tys: &[@ast::ty],
4646
this: state, next: next_state) {
47-
alt next {
48-
some({state: next, tys: next_tys}) {
49-
let proto = this.proto;
50-
if !proto.has_state(next) {
51-
// This should be a span fatal, but then we need to
52-
// track span information.
53-
self.span_err(
54-
empty_span(),
55-
#fmt("message %s steps to undefined state, %s",
56-
*name, *next));
57-
}
58-
59-
let next = proto.get_state(next);
60-
61-
if next.ty_params.len() != next_tys.len() {
47+
alt next {
48+
some({state: next, tys: next_tys}) {
49+
let proto = this.proto;
50+
if !proto.has_state(next) {
51+
// This should be a span fatal, but then we need to
52+
// track span information.
6253
self.span_err(
63-
empty_span(), // use a real span
64-
#fmt("message %s target (%s) \
65-
needs %u type parameters, but got %u",
66-
*name, *next.name,
67-
next.ty_params.len(),
68-
next_tys.len()));
54+
empty_span(),
55+
#fmt("message %s steps to undefined state, %s",
56+
*name, *next));
57+
}
58+
else {
59+
let next = proto.get_state(next);
60+
61+
if next.ty_params.len() != next_tys.len() {
62+
self.span_err(
63+
empty_span(), // use a real span
64+
#fmt("message %s target (%s) \
65+
needs %u type parameters, but got %u",
66+
*name, *next.name,
67+
next.ty_params.len(),
68+
next_tys.len()));
69+
}
6970
}
7071
}
7172
none { }

0 commit comments

Comments
 (0)