Browse Source

catch Exit exception in Context.toComplexType

Simon Krajewski 13 years ago
parent
commit
0f626aab55
2 changed files with 3 additions and 2 deletions
  1. 2 1
      interp.ml
  2. 1 1
      std/haxe/macro/Context.hx

+ 2 - 1
interp.ml

@@ -2170,7 +2170,8 @@ let macro_lib =
 			VString (Digest.to_hex (Digest.string (Marshal.to_string v [Marshal.Closures])))
 		);
 		"to_complex", Fun1 (fun v ->
-			encode_complex_type (make_complex_type (decode_type v))
+			try	encode_complex_type (make_complex_type (decode_type v))
+			with Exit -> VNull
 		);
 		"typeof", Fun1 (fun v ->
 			encode_type ((get_ctx()).curapi.typeof (decode_expr v))

+ 1 - 1
std/haxe/macro/Context.hx

@@ -174,7 +174,7 @@ class Context {
 	/**
 		Returns the ComplexType corresponding to the given Type.
 	**/
-	public static function toComplexType( t : Type ) : ComplexType {
+	public static function toComplexType( t : Type ) : Null<ComplexType> {
 		// TODO: handle TMono -> Unknown somehow
 		return load("to_complex", 1)(t);
 	}