Nicolas Cannasse 19 роки тому
батько
коміт
a91018eec1
2 змінених файлів з 14 додано та 2 видалено
  1. 1 0
      doc/CHANGES.txt
  2. 13 2
      typer.ml

+ 1 - 0
doc/CHANGES.txt

@@ -1,5 +1,6 @@
 2006-??-??: 1.06
 	allowed extern enums
+	use only matching construct when parameters are matched
 
 2006-08-16: 1.05
 	moved Md5 to haxe package.

+ 13 - 2
typer.ml

@@ -1284,8 +1284,19 @@ and type_switch ctx e cases def need_val p =
 		| TMono _ -> lookup_enum (List.map fst cases)
 		| _ -> None
 	) in
-	(* does not treat Bool as an matchable enum, since it's a native type *)
-	let enum = (match enum with None | Some ({ e_path = ([],"Bool") },_) -> None | _ -> enum) in
+	(* does not use match when no case contain parameters (include Bool) *)
+	let enum = (match enum with 
+		| None -> None
+		| Some e ->
+			if List.exists (fun (e,_) -> 
+				match fst e with
+				| ECall _ -> true
+				| _ -> false
+			) cases then
+				Some e
+			else
+				None
+	) in
 	let ecases = ref PMap.empty in
 	let cases = List.map (fun (e1,e2) ->
 		let locals = save_locals ctx in