Typecheck tags in "alt" patterns

This commit is contained in:
Patrick Walton 2010-10-14 15:02:35 -07:00
parent f234750d80
commit c7ab80f743
3 changed files with 26 additions and 0 deletions

View file

@ -903,8 +903,10 @@ let check_stmt (cx:Semant.ctxt) : (fn_ctx -> Ast.stmt -> unit) =
let arg_tys =
match constr_ty with
Ast.TY_fn (ty_sig, _) ->
demand expected (get_slot_ty ty_sig.Ast.sig_output_slot);
Array.map get_slot_ty ty_sig.Ast.sig_input_slots
| Ast.TY_tag _ ->
demand expected constr_ty;
[||]
| _ -> type_error "constructor function" constr_ty
in

View file

@ -0,0 +1,12 @@
// error-pattern: mismatched types
tag a { A; }
tag b { B; }
fn main() {
let a x = A;
alt (x) {
case (B) {}
}
}

View file

@ -0,0 +1,12 @@
// error-pattern: mismatched types
tag a { A(int); }
tag b { B(int); }
fn main() {
let a x = A(0);
alt (x) {
case (B(?y)) {}
}
}