瀏覽代碼

make sure that typeof error get raised

Nicolas Cannasse 14 年之前
父節點
當前提交
1dbd345d85
共有 1 個文件被更改,包括 4 次插入1 次删除
  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 ->