浏览代码

never consider default pattern unused (closes #2267)

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

+ 7 - 6
matcher.ml

@@ -1190,12 +1190,13 @@ let match_expr ctx e cases def with_type p =
 			ctx.on_error <- old_error;
 			ctx.on_error <- old_error;
 		in
 		in
  		PMap.iter (fun _ out -> if not (Hashtbl.mem mctx.used_paths out.o_id) then begin
  		PMap.iter (fun _ out -> if not (Hashtbl.mem mctx.used_paths out.o_id) then begin
-			if out.o_pos == p then display_error ctx "The default pattern is unused" p
-			else unused out.o_pos;
-			if mctx.toplevel_or then begin match evals with
-				| [{etype = t}] when (match follow t with TAbstract({a_path=[],"Int"},[]) -> true | _ -> false) ->
-					display_error ctx "Note: Int | Int is an or-pattern now" p;
-				| _ -> ()
+			if out.o_pos != p then begin
+				unused out.o_pos;
+				if mctx.toplevel_or then begin match evals with
+					| [{etype = t}] when (match follow t with TAbstract({a_path=[],"Int"},[]) -> true | _ -> false) ->
+						display_error ctx "Note: Int | Int is an or-pattern now" p;
+					| _ -> ()
+				end;
 			end;
 			end;
 		end) mctx.outcomes;
 		end) mctx.outcomes;
 	in
 	in