Browse Source

make sure that we are at the PTypeField pass (allows typeof in @:build) fixed issue #1401

Nicolas Cannasse 12 years ago
parent
commit
e915c1c610
1 changed files with 11 additions and 8 deletions
  1. 11 8
      typer.ml

+ 11 - 8
typer.ml

@@ -3011,26 +3011,29 @@ let macro_timer ctx path =
 
 
 let typing_timer ctx f =
 let typing_timer ctx f =
 	let t = Common.timer "typing" in
 	let t = Common.timer "typing" in
-	let old = ctx.com.error in
+	let old = ctx.com.error and oldp = ctx.pass in
 	(*
 	(*
 		disable resumable errors... unless we are in display mode (we want to reach point of completion)
 		disable resumable errors... unless we are in display mode (we want to reach point of completion)
 	*)
 	*)
 	if not ctx.com.display then ctx.com.error <- (fun e p -> raise (Error(Custom e,p)));
 	if not ctx.com.display then ctx.com.error <- (fun e p -> raise (Error(Custom e,p)));
+	if ctx.pass < PTypeField then ctx.pass <- PTypeField;
+	let exit() =
+		t();
+		ctx.com.error <- old;
+		ctx.pass <- oldp;
+	in
 	try
 	try
 		let r = f() in
 		let r = f() in
-		t();
+		exit();
 		r
 		r
 	with Error (ekind,p) ->
 	with Error (ekind,p) ->
-			ctx.com.error <- old;
-			t();
+			exit();
 			Interp.compiler_error (Typecore.error_msg ekind) p
 			Interp.compiler_error (Typecore.error_msg ekind) p
 		| WithTypeError (l,p) ->
 		| WithTypeError (l,p) ->
-			ctx.com.error <- old;
-			t();
+			exit();
 			Interp.compiler_error (Typecore.error_msg (Unify l)) p
 			Interp.compiler_error (Typecore.error_msg (Unify l)) p
 		| e ->
 		| e ->
-			ctx.com.error <- old;
-			t();
+			exit();
 			raise e
 			raise e
 
 
 let make_macro_api ctx p =
 let make_macro_api ctx p =