瀏覽代碼

give better error message

Simon Krajewski 12 年之前
父節點
當前提交
bc0833e342
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 5 1
      typeload.ml
  2. 3 0
      typer.ml

+ 5 - 1
typeload.ml

@@ -1715,8 +1715,12 @@ let init_class ctx c p context_init herits fields =
 			let rec loop = function
 				| [] -> check_require l
 				| e :: l ->
+					let sc = match fst e with
+						| EConst (Ident s) -> s
+						| _ -> ""
+					in
 					if not (Parser.is_true (Parser.eval ctx.com e)) then
-						Some ("condition",(match List.rev l with (EConst (String msg),_) :: _ -> Some msg | _ -> None))
+						Some (sc,(match List.rev l with (EConst (String msg),_) :: _ -> Some msg | _ -> None))
 					else
 						loop l
 			in

+ 3 - 0
typer.ml

@@ -762,6 +762,9 @@ let rec acc_get ctx g p =
 		assert false
 
 let error_require r p =
+	if r = "" then
+		error "This field is not available with the current compilation flags" p
+	else
 	let r = if r = "sys" then
 		"a system platform (php,neko,cpp,etc.)"
 	else try