Selaa lähdekoodia

make sure that typeof error get raised

Nicolas Cannasse 14 vuotta sitten
vanhempi
commit
1dbd345d85
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      typer.ml

+ 4 - 1
typer.ml

@@ -1970,7 +1970,10 @@ let make_macro_api ctx p =
 			| _ -> assert false
 		);
 		Interp.typeof = (fun e ->
-			let e = (try type_expr ctx ~need_val:true e with Error (msg,_) -> failwith (error_msg msg)) in
+			let old_err = ctx.com.error in
+			ctx.com.error <- (fun e p -> raise (Error(Custom e,p)));
+			let e = (try type_expr ctx ~need_val:true e with Error (msg,_) -> ctx.com.error <- old_err; failwith (error_msg msg)) in
+			ctx.com.error <- old_err;
 			e.etype
 		);
 		Interp.type_patch = (fun t f s v ->