Forráskód Böngészése

restrict constructor list to the ones that unify for GADT (fixed issue #1300)

Nicolas Cannasse 12 éve
szülő
commit
06f90a46bb
1 módosított fájl, 3 hozzáadás és 1 törlés
  1. 3 1
      typer.ml

+ 3 - 1
typer.ml

@@ -1560,8 +1560,10 @@ and type_switch_old ctx e cases def need_val with_type p =
 		(match def with
 		| Some _ -> ()
 		| None ->
+			let tenum = TEnum(enum,enparams) in
 			let l = PMap.fold (fun c acc ->
-				if Hashtbl.mem used_cases c.ef_name then acc else c.ef_name :: acc
+				let t = monomorphs enum.e_types (monomorphs c.ef_params c.ef_type) in
+				if Hashtbl.mem used_cases c.ef_name || not (try unify_raise ctx t tenum c.ef_pos; true with Error (Unify _,_) -> false) then acc else c.ef_name :: acc
 			) enum.e_constrs [] in
 			match l with
 			| [] -> ()