Browse Source

expand or-patterns in tuples too

Simon Krajewski 11 years ago
parent
commit
1cc5fad8e6
1 changed files with 14 additions and 0 deletions
  1. 14 0
      matcher.ml

+ 14 - 0
matcher.ml

@@ -697,6 +697,20 @@ let expand_or mctx pmat =
 					let tl = array_tl pv in
 					let tl = array_tl pv in
 					loop2 (Array.append [|{pat with p_def = PBind(v,pat2)}|] tl) out2;
 					loop2 (Array.append [|{pat with p_def = PBind(v,pat2)}|] tl) out2;
 					loop2 (Array.append [|{pat with p_def = PBind(v,pat1)}|] tl) out;
 					loop2 (Array.append [|{pat with p_def = PBind(v,pat1)}|] tl) out;
+				| {p_def = PTuple tl} as pat ->
+					begin match tl.(0).p_def with
+					 	| POr(pat1,pat2) ->
+							let out2 = clone_out mctx out pat2.p_pos in
+							let tl = array_tl pv in
+							let a1 = Array.copy tl in
+							tl.(0) <- pat1;
+							let a2 = Array.copy tl in
+							tl.(0) <- pat2;
+							loop2 (Array.append [|{pat with p_def = PTuple a2}|] tl) out2;
+							loop2 (Array.append [|{pat with p_def = PTuple a1}|] tl) out;
+					 	| _ ->
+					 		acc := (pv,out) :: !acc
+					 end
 				| _ ->
 				| _ ->
 					acc := (pv,out) :: !acc
 					acc := (pv,out) :: !acc
 			in
 			in