浏览代码

give better error message if tuple is bound (closes #2197)

Simon Krajewski 12 年之前
父节点
当前提交
3e26839f0b
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      matcher.ml

+ 4 - 3
matcher.ml

@@ -442,11 +442,12 @@ let to_pattern ctx e t =
 					| _ ->
 						raise Not_found);
 			with Not_found ->
-				if not (is_lower_ident s) && s.[0] <> '`' then error "Capture variables must be lower-case" p;
 				begin match get_tuple_types t with
-					| Some _ ->
-						error "Cannot bind tuple" p
+					| Some tl ->
+						let s = String.concat "," (List.map (fun (_,_,t) -> s_type t) tl) in
+						error ("Pattern should be tuple [" ^ s ^ "]") p
 					| None ->
+						if not (is_lower_ident s) && s.[0] <> '`' then error "Capture variables must be lower-case" p;
 						let v = mk_var pctx s t p in
 						mk_pat (PVar (v,p)) v.v_type p
 				end