فهرست منبع

report current target upon forbidden package (fixed issue #1215)

Simon Krajewski 13 سال پیش
والد
کامیت
e4a71f29a0
3فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 2 2
      main.ml
  2. 1 1
      typecore.ml
  3. 3 3
      typeload.ml

+ 2 - 2
main.ml

@@ -1116,11 +1116,11 @@ with
 		error ctx (Lexer.error_msg m) p
 	| Parser.Error (m,p) ->
 		error ctx (Parser.error_msg m) p
-	| Typecore.Forbid_package ((pack,m,p),pl)  ->
+	| Typecore.Forbid_package ((pack,m,p),pl,pf)  ->
 		if !Common.display_default && ctx.has_next then
 			()
 		else begin
-			error ctx ("You can't access the " ^ pack ^ " package with current compilation flags (for " ^ Ast.s_type_path m ^ ")") p;
+			error ctx (Printf.sprintf "You cannot access the %s package while %s (for %s)" pack (if pf = "macro" then "in a macro" else "targeting " ^ pf) (Ast.s_type_path m) ) p;
 			List.iter (error ctx "    referenced here") (List.rev pl);
 		end
 	| Typecore.Error (m,p) ->

+ 1 - 1
typecore.ml

@@ -115,7 +115,7 @@ type error_msg =
 
 exception Fatal_error
 
-exception Forbid_package of (string * path * pos) * pos list
+exception Forbid_package of (string * path * pos) * pos list * string
 
 exception Error of error_msg * pos
 

+ 3 - 3
typeload.ml

@@ -1813,7 +1813,7 @@ let resolve_module_file com m remap p =
 		| x :: l , name ->
 			let x = (try
 				match PMap.find x com.package_rules with
-				| Forbidden -> raise (Forbid_package ((x,m,p),[]));
+				| Forbidden -> raise (Forbid_package ((x,m,p),[],platform_name com.platform));
 				| Directory d -> d
 				| Remap d -> remap := d :: l; d
 				with Not_found -> x
@@ -1893,8 +1893,8 @@ let load_module ctx m p =
 			) in
 			try
 				type_module ctx m file decls p
-			with Forbid_package (inf,pl) when p <> Ast.null_pos ->
-				raise (Forbid_package (inf,p::pl))
+			with Forbid_package (inf,pl,pf) when p <> Ast.null_pos ->
+				raise (Forbid_package (inf,p::pl,if ctx.in_macro then "macro" else pf))
 	) in
 	add_dependency ctx.m.curmod m2;
 	if ctx.pass = PTypeField then flush_pass ctx PBuildClass "load_module";