Pārlūkot izejas kodu

Move warning list to prebuild (#10666)

* move warning generation to prebuild

* allow using warning identifiers

* more warnings

* adjust tests

* completely change everything

* shut up the unit tests again
Simon Krajewski 3 gadi atpakaļ
vecāks
revīzija
9757785029
36 mainītis faili ar 395 papildinājumiem un 217 dzēšanām
  1. 107 0
      src-json/warning.json
  2. 90 0
      src-prebuild/prebuild.ml
  3. 10 10
      src/codegen/gencommon/castDetect.ml
  4. 3 3
      src/codegen/gencommon/closuresToClass.ml
  5. 1 1
      src/codegen/gencommon/gencommon.ml
  6. 3 3
      src/codegen/gencommon/initFunction.ml
  7. 1 1
      src/codegen/gencommon/unreachableCodeEliminationSynf.ml
  8. 6 0
      src/compiler/compiler.ml
  9. 6 0
      src/core/dune
  10. 23 71
      src/core/warning.ml
  11. 2 2
      src/optimization/analyzerConfig.ml
  12. 1 1
      src/optimization/inlineConstructors.ml
  13. 4 4
      src/typing/matcher.ml
  14. 1 1
      src/typing/typeloadFields.ml
  15. 1 1
      tests/misc/projects/Issue10184/check-warning.hxml.stderr
  16. 10 10
      tests/misc/projects/Issue2508/compile.hxml.stderr
  17. 24 24
      tests/misc/projects/Issue4720/compile.hxml.stderr
  18. 1 1
      tests/misc/projects/Issue6226/compile.hxml.stderr
  19. 1 1
      tests/misc/projects/Issue7096/compile.hxml.stderr
  20. 2 2
      tests/misc/projects/Issue7447/compile.hxml.stderr
  21. 1 1
      tests/misc/projects/Issue7669/compile-fail.hxml.stderr
  22. 1 1
      tests/misc/projects/Issue8471/compile2.hxml.stderr
  23. 1 1
      tests/misc/projects/Issue9192/compile.hxml.stderr
  24. 1 1
      tests/misc/projects/Issue9204/compile.hxml.stderr
  25. 1 1
      tests/misc/projects/Issue9425/compile-success.hxml.stderr
  26. 1 2
      tests/unit/compile-each.hxml
  27. 2 2
      tests/unit/src/unit/TestGADT.hx
  28. 12 7
      tests/unit/src/unit/TestGeneric.hx
  29. 13 10
      tests/unit/src/unit/TestRest.hx
  30. 58 50
      tests/unit/src/unit/UnitBuilder.hx
  31. 1 1
      tests/unit/src/unit/issues/Issue10073.hx
  32. 1 0
      tests/unit/src/unit/issues/Issue10304.hx
  33. 1 1
      tests/unit/src/unit/issues/Issue2778.hx
  34. 2 1
      tests/unit/src/unit/issues/Issue3861.hx
  35. 1 1
      tests/unit/src/unit/issues/Issue4578.hx
  36. 1 1
      tests/unit/src/unit/issues/Issue6561.hx

+ 107 - 0
src-json/warning.json

@@ -0,0 +1,107 @@
+[
+	{
+		"name": "WAll",
+		"doc": "The mother of all warnings",
+		"generic": true
+	},
+	{
+		"name": "WInternal",
+		"doc": "Reserved for internal use",
+		"generic": true
+	},
+	{
+		"name": "WTemp",
+		"doc": "Reserved for internal use",
+		"generic": true
+	},
+	{
+		"name": "WInfo",
+		"doc": "Generic information like $type",
+		"generic": true
+	},
+	{
+		"name": "WUser",
+		"doc": "Custom user warnings, e.g. from Context.warning",
+		"generic": true
+	},
+	{
+		"name": "WCompiler",
+		"doc": "Warnings from the compiler frontend, e.g. argument parsing",
+		"generic": true
+	},
+	{
+		"name": "WParser",
+		"doc": "Warnings related to lexing and parsing",
+		"generic": true
+	},
+	{
+		"name": "WTyper",
+		"doc": "Warnings from the typer",
+		"generic": true
+	},
+	{
+		"name": "WMacro",
+		"doc": "Warning related to macros",
+		"generic": true
+	},
+	{
+		"name": "WOptimizer",
+		"doc": "Warnings related to optimization",
+		"generic": true
+	},
+	{
+		"name": "WGenerator",
+		"doc": "Warnings related to code generation",
+		"generic": true
+	},
+	{
+		"name": "WDeprecated",
+		"doc": "This is deprecated and should no longer be used"
+	},
+	{
+		"name": "WVarInit",
+		"doc": "A local variable might be used before being assigned a value",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WVarShadow",
+		"doc": "A local variable hides another by using the same name",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WExternWithExpr",
+		"doc": "A non-inline field marked as extern has an expression",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WStaticInitOrder",
+		"doc": "The compiler could not determine a type order due to mutually dependent static initializations",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WClosureCompare",
+		"doc": "Closures are being compared, which might be undefined",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WReservedTypePath",
+		"doc": "A type path is being used that is supposed to be reserved on the current target",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WPatternMatcher",
+		"doc": "Warnings related to the pattern matcher",
+		"parent": "WTyper"
+	},
+	{
+		"name": "WUnusedPattern",
+		"doc": "The pattern is not used because previous cases cover",
+		"parent": "WPatternMatcher"
+	},
+	{
+		"name": "WConstructorInliningCancelled",
+		"doc": "Constructor call could not be inlined because a field is uninitialized",
+		"parent": "WTyper"
+	}
+
+]

+ 90 - 0
src-prebuild/prebuild.ml

@@ -2,10 +2,21 @@ open Json
 
 
 exception Prebuild_error of string
 exception Prebuild_error of string
 
 
+type parsed_warning = {
+	w_name : string;
+	w_doc : string;
+	w_parent : string option;
+	w_generic : bool;
+}
+
 let as_string = function
 let as_string = function
 	| JString s -> Some s
 	| JString s -> Some s
 	| _ -> None
 	| _ -> None
 
 
+let as_int = function
+	| JInt i -> Some i
+	| _ -> None
+
 let as_params = function
 let as_params = function
 	| JArray s -> Some (List.map (function
 	| JArray s -> Some (List.map (function
 			| JString s -> s
 			| JString s -> s
@@ -66,6 +77,16 @@ let get_optional_field name map default fields =
 		| Some v -> v
 		| Some v -> v
 	with Not_found -> default
 	with Not_found -> default
 
 
+let get_optional_field2 name map fields =
+	try
+		let field = List.find (fun (n, _) -> n = name) fields in
+		let value = map (snd field) in
+		match value with
+		| None -> raise (Prebuild_error ("field `" ^ name ^ "` has invalid data"))
+		| Some v -> Some v
+	with Not_found ->
+		None
+
 let get_field name map fields =
 let get_field name map fields =
 	let field = try List.find (fun (n, _) -> n = name) fields with Not_found -> raise (Prebuild_error ("no `" ^ name ^ "` field")) in
 	let field = try List.find (fun (n, _) -> n = name) fields with Not_found -> raise (Prebuild_error ("no `" ^ name ^ "` field")) in
 	let value = map (snd field) in
 	let value = map (snd field) in
@@ -99,6 +120,18 @@ let parse_meta json =
 	(* internal *) get_optional_field "internal" as_bool false fields,
 	(* internal *) get_optional_field "internal" as_bool false fields,
 	(* links *) get_optional_field "links" as_links [] fields
 	(* links *) get_optional_field "links" as_links [] fields
 
 
+let parse_warning json =
+	let fields = match json with
+		| JObject fl -> fl
+		| _ -> raise (Prebuild_error "not an object")
+	in
+	{
+		w_name = get_field "name" as_string fields;
+		w_doc = get_field "doc" as_string fields;
+		w_parent = get_optional_field2 "parent" as_string fields;
+		w_generic = get_optional_field "generic" as_bool false fields;
+	}
+
 let parse_file_array path map =
 let parse_file_array path map =
 	let file = open_in path in
 	let file = open_in path in
 	let data = Std.input_all file in
 	let data = Std.input_all file in
@@ -109,6 +142,20 @@ let parse_file_array path map =
 	| JArray s -> List.map map s
 	| JArray s -> List.map map s
 	| _ -> raise (Prebuild_error "not an array")
 	| _ -> raise (Prebuild_error "not an array")
 
 
+let s_escape ?(hex=true) s =
+	let b = Buffer.create (String.length s) in
+	for i = 0 to (String.length s) - 1 do
+		match s.[i] with
+		| '\n' -> Buffer.add_string b "\\n"
+		| '\t' -> Buffer.add_string b "\\t"
+		| '\r' -> Buffer.add_string b "\\r"
+		| '"' -> Buffer.add_string b "\\\""
+		| '\\' -> Buffer.add_string b "\\\\"
+		| c when int_of_char c < 32 && hex -> Buffer.add_string b (Printf.sprintf "\\x%.2X" (int_of_char c))
+		| c -> Buffer.add_char b c
+	done;
+	Buffer.contents b
+
 let gen_platforms = function
 let gen_platforms = function
 	| [] -> []
 	| [] -> []
 	| platforms -> ["Platforms [" ^ (String.concat ";" platforms) ^ "]"]
 	| platforms -> ["Platforms [" ^ (String.concat ";" platforms) ^ "]"]
@@ -157,6 +204,32 @@ let gen_meta_info metas =
 	) metas in
 	) metas in
 	String.concat "\n" meta_str
 	String.concat "\n" meta_str
 
 
+let gen_warning_type warnings =
+	let warning_str = List.map (function
+		w ->
+			Printf.sprintf "\t| %s" w.w_name
+	) warnings in
+	String.concat "\n" warning_str
+
+let gen_warning_parse warnings =
+	let warning_str = List.map (function
+		w ->
+			Printf.sprintf "\t| \"%s\" -> %s" w.w_name w.w_name
+	) warnings in
+	let warning_str = warning_str @ ["\t| _ -> raise Exit"] in
+	String.concat "\n" warning_str
+
+
+let gen_warning_obj warnings =
+	let warning_str = List.map (fun w ->
+		let w_parent = match w.w_parent with
+			| None -> if w.w_name = "WAll" then "None" else "Some WAll"
+			| Some w -> Printf.sprintf "Some %s" w
+		in
+		Printf.sprintf "\t| %s -> {w_name = \"%s\"; w_doc = \"%s\"; w_generic = %b; w_parent = %s}" w.w_name w.w_name (s_escape w.w_doc) w.w_generic w_parent
+	) warnings in
+	String.concat "\n" warning_str
+
 let autogen_header = "(* This file is auto-generated using prebuild from files in src-json *)
 let autogen_header = "(* This file is auto-generated using prebuild from files in src-json *)
 (* Do not edit manually! *)
 (* Do not edit manually! *)
 "
 "
@@ -216,6 +289,23 @@ match Array.to_list (Sys.argv) with
 		Printf.printf "let get_info = function\n";
 		Printf.printf "let get_info = function\n";
 		Printf.printf "%s" (gen_meta_info metas);
 		Printf.printf "%s" (gen_meta_info metas);
 		Printf.printf "\n\t| Last -> die \"\" __LOC__\n\t| Dollar s -> \"$\" ^ s,(\"\",[])\n\t| Custom s -> s,(\"\",[])\n"
 		Printf.printf "\n\t| Last -> die \"\" __LOC__\n\t| Dollar s -> \"$\" ^ s,(\"\",[])\n\t| Custom s -> s,(\"\",[])\n"
+	| [_; "warning"; warning_path]->
+		let warnings = parse_file_array warning_path parse_warning in
+		print_endline "type warning =";
+		print_endline (gen_warning_type warnings);
+		print_endline "";
+		print_endline "type warning_obj = {";
+		print_endline "\tw_name : string;";
+		print_endline "\tw_doc : string;";
+		print_endline "\tw_generic : bool;";
+		print_endline "\tw_parent : warning option;";
+		print_endline "}";
+		print_endline "";
+		print_endline "let warning_obj = function";
+		print_endline (gen_warning_obj warnings);
+		print_endline "";
+		print_endline "let from_string = function";
+		print_endline (gen_warning_parse warnings);
 	| _ :: "libparams" :: params ->
 	| _ :: "libparams" :: params ->
 		Printf.printf "(%s)" (String.concat " " (List.map (fun s -> Printf.sprintf "\"%s\"" s) params))
 		Printf.printf "(%s)" (String.concat " " (List.map (fun s -> Printf.sprintf "\"%s\"" s) params))
 	| [_ ;"version";add_revision;branch;sha] ->
 	| [_ ;"version";add_revision;branch;sha] ->

+ 10 - 10
src/codegen/gencommon/castDetect.ml

@@ -767,12 +767,12 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 						| [Cannot_unify (b, TAbstract(a,params))] ->
 						| [Cannot_unify (b, TAbstract(a,params))] ->
 							let a = apply_params a.a_params params a.a_this in
 							let a = apply_params a.a_params params a.a_this in
 							if not (shallow_eq a b) then
 							if not (shallow_eq a b) then
-								gen.gwarning WGencommon ("This expression may be invalid") pos
+								gen.gwarning WGenerator ("This expression may be invalid") pos
 						| _ ->
 						| _ ->
-							gen.gwarning WGencommon ("This expression may be invalid") pos
+							gen.gwarning WGenerator ("This expression may be invalid") pos
 						)
 						)
 				| Invalid_argument _ ->
 				| Invalid_argument _ ->
-						gen.gwarning WGencommon ("This expression may be invalid") pos
+						gen.gwarning WGenerator ("This expression may be invalid") pos
 			);
 			);
 
 
 			List.map (fun t ->
 			List.map (fun t ->
@@ -824,7 +824,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 						(* f,f.cf_type, false *)
 						(* f,f.cf_type, false *)
 						select_overload gen e1.etype ((f.cf_type,f) :: List.map (fun f -> f.cf_type,f) f.cf_overloads) [] [], true
 						select_overload gen e1.etype ((f.cf_type,f) :: List.map (fun f -> f.cf_type,f) f.cf_overloads) [] [], true
 					| _ ->
 					| _ ->
-						gen.gwarning WGencommon "Overloaded classfield typed as anonymous" ecall.epos;
+						gen.gwarning WGenerator "Overloaded classfield typed as anonymous" ecall.epos;
 						(cf, actual_t, true), true
 						(cf, actual_t, true), true
 				in
 				in
 
 
@@ -847,7 +847,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 					end;
 					end;
 					{ cf_orig with cf_name = cf.cf_name },actual_t,false
 					{ cf_orig with cf_name = cf.cf_name },actual_t,false
 				| None ->
 				| None ->
-					gen.gwarning WGencommon "Cannot find matching overload" ecall.epos;
+					gen.gwarning WGenerator "Cannot find matching overload" ecall.epos;
 					cf, actual_t, true
 					cf, actual_t, true
 				else
 				else
 					cf,actual_t,error
 					cf,actual_t,error
@@ -929,7 +929,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 							elist);
 							elist);
 					}, elist
 					}, elist
 				with Invalid_argument _ ->
 				with Invalid_argument _ ->
-					gen.gwarning WGencommon ("This expression may be invalid" ) ecall.epos;
+					gen.gwarning WGenerator ("This expression may be invalid" ) ecall.epos;
 					{ ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist) }, elist
 					{ ecall with eexpr = TCall({ e1 with eexpr = TField(!ef, f) }, elist) }, elist
 				in
 				in
 				let new_ecall = if fparams <> [] then gen.gparam_func_call new_ecall { e1 with eexpr = TField(!ef, f) } fparams elist else new_ecall in
 				let new_ecall = if fparams <> [] then gen.gparam_func_call new_ecall { e1 with eexpr = TField(!ef, f) } fparams elist else new_ecall in
@@ -959,7 +959,7 @@ let handle_type_parameter gen e e1 ef ~clean_ef ~overloads_cast_to_base f elist
 		*)
 		*)
 			| _ ->
 			| _ ->
 				let pt = match e with | None -> real_type | Some _ -> snd (get_fun e1.etype) in
 				let pt = match e with | None -> real_type | Some _ -> snd (get_fun e1.etype) in
-				let _params = match follow pt with | TEnum(_, p) -> p | _ -> gen.gwarning WGencommon (debug_expr e1) e1.epos; die "" __LOC__ in
+				let _params = match follow pt with | TEnum(_, p) -> p | _ -> gen.gwarning WGenerator (debug_expr e1) e1.epos; die "" __LOC__ in
 				let args, ret = get_fun efield.ef_type in
 				let args, ret = get_fun efield.ef_type in
 				let actual_t = TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret) in
 				let actual_t = TFun(List.map (fun (n,o,t) -> (n,o,gen.greal_type t)) args, gen.greal_type ret) in
 				(*
 				(*
@@ -1143,7 +1143,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
 				let base_type = match follow et with
 				let base_type = match follow et with
 					| TInst({ cl_path = ([], "Array") } as cl, bt) -> gen.greal_type_param (TClassDecl cl) bt
 					| TInst({ cl_path = ([], "Array") } as cl, bt) -> gen.greal_type_param (TClassDecl cl) bt
 					| _ ->
 					| _ ->
-						gen.gwarning WGencommon (debug_type et) e.epos;
+						gen.gwarning WGenerator (debug_type et) e.epos;
 						(match gen.gcurrent_class with
 						(match gen.gcurrent_class with
 							| Some cl -> print_endline (s_type_path cl.cl_path)
 							| Some cl -> print_endline (s_type_path cl.cl_path)
 							| _ -> ());
 							| _ -> ());
@@ -1187,7 +1187,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
 					) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
 					) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
 					{ e with eexpr = TCall(ef, eparams) }
 					{ e with eexpr = TCall(ef, eparams) }
 				with | Not_found ->
 				with | Not_found ->
-					gen.gwarning WGencommon "No overload found for this constructor call" e.epos;
+					gen.gwarning WGenerator "No overload found for this constructor call" e.epos;
 					{ e with eexpr = TCall(ef, List.map run eparams) })
 					{ e with eexpr = TCall(ef, List.map run eparams) })
 			| TCall (ef, eparams) ->
 			| TCall (ef, eparams) ->
 				(match ef.etype with
 				(match ef.etype with
@@ -1215,7 +1215,7 @@ let configure gen ?(overloads_cast_to_base = false) maybe_empty_t calls_paramete
 				) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
 				) (wrap_rest_args gen (TFun (args,rt)) eparams e.epos) args in
 				{ e with eexpr = TNew(cl, tparams, eparams) }
 				{ e with eexpr = TNew(cl, tparams, eparams) }
 			with | Not_found ->
 			with | Not_found ->
-				gen.gwarning WGencommon "No overload found for this constructor call" e.epos;
+				gen.gwarning WGenerator "No overload found for this constructor call" e.epos;
 				{ e with eexpr = TNew(cl, tparams, List.map run eparams) })
 				{ e with eexpr = TNew(cl, tparams, List.map run eparams) })
 			| TUnop((Increment | Decrement) as op, flag, ({ eexpr = TArray (arr, idx) } as e2))
 			| TUnop((Increment | Decrement) as op, flag, ({ eexpr = TArray (arr, idx) } as e2))
 				when (match follow arr.etype with TInst({ cl_path = ["cs"],"NativeArray" },_) -> true | _ -> false) ->
 				when (match follow arr.etype with TInst({ cl_path = ["cs"],"NativeArray" },_) -> true | _ -> false) ->

+ 3 - 3
src/codegen/gencommon/closuresToClass.ml

@@ -627,7 +627,7 @@ let configure gen ft =
 		with
 		with
 			| Not_found ->
 			| Not_found ->
 				if in_tparam then begin
 				if in_tparam then begin
-					gen.gwarning WGencommon "This expression may be invalid" e.epos;
+					gen.gwarning WGenerator "This expression may be invalid" e.epos;
 					e
 					e
 				end else
 				end else
 					(* It is possible that we are recursively calling a function
 					(* It is possible that we are recursively calling a function
@@ -642,8 +642,8 @@ let configure gen ft =
 						(Meta.Custom(":tparamcall"), [], e.epos), e
 						(Meta.Custom(":tparamcall"), [], e.epos), e
 					) }
 					) }
 			| Unify_error el ->
 			| Unify_error el ->
-				List.iter (fun el -> gen.gwarning WGencommon (Error.unify_error_msg (print_context()) el) e.epos) el;
-				gen.gwarning WGencommon "This expression may be invalid" e.epos;
+				List.iter (fun el -> gen.gwarning WGenerator (Error.unify_error_msg (print_context()) el) e.epos) el;
+				gen.gwarning WGenerator "This expression may be invalid" e.epos;
 				e
 				e
 		)
 		)
 		(* (handle_anon_func:texpr->tfunc->texpr) (dynamic_func_call:texpr->texpr->texpr list->texpr) *)
 		(* (handle_anon_func:texpr->tfunc->texpr) (dynamic_func_call:texpr->texpr->texpr list->texpr) *)

+ 1 - 1
src/codegen/gencommon/gencommon.ml

@@ -619,7 +619,7 @@ let new_ctx con =
 
 
 		greal_field_types = Hashtbl.create 0;
 		greal_field_types = Hashtbl.create 0;
 		ghandle_cast = (fun to_t from_t e -> mk_cast to_t e);
 		ghandle_cast = (fun to_t from_t e -> mk_cast to_t e);
-		gon_unsafe_cast = (fun t t2 pos -> (gen.gwarning WGencommon ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos));
+		gon_unsafe_cast = (fun t t2 pos -> (gen.gwarning WGenerator ("Type " ^ (debug_type t2) ^ " is being cast to the unrelated type " ^ (s_type (print_context()) t)) pos));
 		gneeds_box = (fun t -> false);
 		gneeds_box = (fun t -> false);
 		gspecial_needs_cast = (fun to_t from_t -> false);
 		gspecial_needs_cast = (fun to_t from_t -> false);
 		gsupported_conversions = Hashtbl.create 0;
 		gsupported_conversions = Hashtbl.create 0;

+ 3 - 3
src/codegen/gencommon/initFunction.ml

@@ -79,9 +79,9 @@ let handle_class gen cl =
 	let init = List.fold_left (fun acc cf ->
 	let init = List.fold_left (fun acc cf ->
 		match cf.cf_kind with
 		match cf.cf_kind with
 			| Var v when Meta.has Meta.ReadOnly cf.cf_meta ->
 			| Var v when Meta.has Meta.ReadOnly cf.cf_meta ->
-					if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gwarning WGencommon "@:readOnly variable declared without `never` setter modifier" cf.cf_pos;
+					if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gwarning WGenerator "@:readOnly variable declared without `never` setter modifier" cf.cf_pos;
 					(match cf.cf_expr with
 					(match cf.cf_expr with
-					| None -> gen.gwarning WGencommon "Uninitialized readonly variable" cf.cf_pos
+					| None -> gen.gwarning WGenerator "Uninitialized readonly variable" cf.cf_pos
 					| Some e -> ensure_simple_expr gen.gcon e);
 					| Some e -> ensure_simple_expr gen.gcon e);
 					acc
 					acc
 			| Var _
 			| Var _
@@ -116,7 +116,7 @@ let handle_class gen cl =
 	let vars, funs = List.fold_left (fun (acc_vars,acc_funs) cf ->
 	let vars, funs = List.fold_left (fun (acc_vars,acc_funs) cf ->
 		match cf.cf_kind with
 		match cf.cf_kind with
 		| Var v when Meta.has Meta.ReadOnly cf.cf_meta ->
 		| Var v when Meta.has Meta.ReadOnly cf.cf_meta ->
-				if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gwarning WGencommon "@:readOnly variable declared without `never` setter modifier" cf.cf_pos;
+				if v.v_write <> AccNever && not (Meta.has Meta.CoreApi cl.cl_meta) then gen.gwarning WGenerator "@:readOnly variable declared without `never` setter modifier" cf.cf_pos;
 				Option.may (ensure_simple_expr com) cf.cf_expr;
 				Option.may (ensure_simple_expr com) cf.cf_expr;
 				(acc_vars,acc_funs)
 				(acc_vars,acc_funs)
 		| Var _
 		| Var _

+ 1 - 1
src/codegen/gencommon/unreachableCodeEliminationSynf.ml

@@ -67,7 +67,7 @@ let init gen java_mode =
 	let should_warn = false in
 	let should_warn = false in
 
 
 	let do_warn =
 	let do_warn =
-		if should_warn then gen.gwarning WGencommon "Unreachable code" else (fun pos -> ())
+		if should_warn then gen.gwarning WGenerator "Unreachable code" else (fun pos -> ())
 	in
 	in
 
 
 	let return_loop expr kind =
 	let return_loop expr kind =

+ 6 - 0
src/compiler/compiler.ml

@@ -215,6 +215,12 @@ module Setup = struct
 		com.warning <- (fun w options msg p ->
 		com.warning <- (fun w options msg p ->
 			match Warning.get_mode w (com.warning_options @ options) with
 			match Warning.get_mode w (com.warning_options @ options) with
 			| WMEnable ->
 			| WMEnable ->
+				let wobj = Warning.warning_obj w in
+				let msg = if wobj.w_generic then
+					msg
+				else
+					Printf.sprintf "(%s) %s" wobj.w_name msg
+				in
 				message ctx (msg,p,DKCompilerMessage,Warning)
 				message ctx (msg,p,DKCompilerMessage,Warning)
 			| WMDisable ->
 			| WMDisable ->
 				()
 				()

+ 6 - 0
src/core/dune

@@ -8,4 +8,10 @@
 	(targets defineList.ml)
 	(targets defineList.ml)
 	(deps ../../src-json/define.json)
 	(deps ../../src-json/define.json)
 	(action (with-stdout-to defineList.ml (run %{bin:haxe_prebuild} define ../../src-json/define.json)))
 	(action (with-stdout-to defineList.ml (run %{bin:haxe_prebuild} define ../../src-json/define.json)))
+)
+
+(rule
+	(targets warningList.ml)
+	(deps ../../src-json/warning.json)
+	(action (with-stdout-to warningList.ml (run %{bin:haxe_prebuild} warning ../../src-json/warning.json)))
 )
 )

+ 23 - 71
src/core/warning.ml

@@ -1,89 +1,41 @@
 open Globals
 open Globals
 open Error
 open Error
-
-type warning =
-	(* general *)
-	| WInternal
-	| WInfo
-	| WUser
-	| WTemp
-	(* subsystem *)
-	| WTyper
-	| WMatcher
-	| WMacro
-	| WAnalyzer
-	| WInliner
-	| WGencommon
-	| WGenerator
-	(* specific *)
-	| WDeprecated
-	| WVarShadow
-	| WExternInit
-	| WStaticInitOrder
-	| WClosureCompare
-	| WVarInit
-	| WReservedTypePath
-
-type warning_range =
-	| WRExact of int
-	| WRRange of int * int
+include WarningList
 
 
 type warning_mode =
 type warning_mode =
 	| WMEnable
 	| WMEnable
 	| WMDisable
 	| WMDisable
 
 
 type warning_option = {
 type warning_option = {
-	wo_range : warning_range;
-	wo_mode  : warning_mode;
+	wo_warning : warning;
+	wo_mode : warning_mode;
 }
 }
 
 
-let warning_id = function
-	| WInternal -> 0
-	| WInfo -> 1
-	| WUser -> 2
-	| WTemp -> 3
-	(* subsystem *)
-	| WTyper -> 100
-	| WMacro -> 200
-	| WMatcher -> 300
-	| WInliner -> 400
-	| WAnalyzer -> 500
-	| WGencommon -> 600
-	| WGenerator -> 700
-	(* specific *)
-	| WDeprecated -> 101
-	| WVarInit -> 102
-	| WVarShadow -> 103
-	| WExternInit -> 104
-	| WStaticInitOrder -> 105
-	| WClosureCompare -> 106
-	| WReservedTypePath -> 107
-
 let parse_options s ps lexbuf =
 let parse_options s ps lexbuf =
 	let fail msg p =
 	let fail msg p =
 		Error.typing_error msg {p with pmin = ps.pmin + p.pmin; pmax = ps.pmin + p.pmax}
 		Error.typing_error msg {p with pmin = ps.pmin + p.pmin; pmax = ps.pmin + p.pmax}
 	in
 	in
-	let parse_range () = match Lexer.token lexbuf with
-		| Const (Int(i,_)),_ ->
-			WRExact (int_of_string i)
-		| IntInterval i1,_ ->
-			begin match Lexer.token lexbuf with
-			| Const (Int(i2,_)),_ ->
-				WRRange(int_of_string i1,int_of_string i2)
-			| (_,p) ->
-				fail "Expected number" p
-			end
+	let parse_string s p =
+		begin try
+			from_string s
+		with Exit ->
+			fail (Printf.sprintf "Unknown warning: %s" s) p
+		end
+	in
+	let parse_warning () = match Lexer.token lexbuf with
+		| Const (Ident s),p ->
+			parse_string s p
 		| (_,p) ->
 		| (_,p) ->
-			fail "Expected number" p
+			fail "Expected identifier" p
 	in
 	in
-	let add acc mode range =
-		{ wo_range = range; wo_mode = mode } :: acc
+	let add acc mode warning =
+		{ wo_warning = warning; wo_mode = mode } :: acc
 	in
 	in
 	let rec next acc = match Lexer.token lexbuf with
 	let rec next acc = match Lexer.token lexbuf with
 		| Binop OpAdd,_ ->
 		| Binop OpAdd,_ ->
-			next (add acc WMEnable (parse_range()))
+			next (add acc WMEnable (parse_warning()))
 		| Binop OpSub,_ ->
 		| Binop OpSub,_ ->
-			next (add acc WMDisable (parse_range()))
+			next (add acc WMDisable (parse_warning()))
 		| Eof,_ ->
 		| Eof,_ ->
 			List.rev acc
 			List.rev acc
 		| (_,p) ->
 		| (_,p) ->
@@ -122,10 +74,10 @@ let from_meta ml =
 	loop [] ml
 	loop [] ml
 
 
 let get_mode w (l : warning_option list list) =
 let get_mode w (l : warning_option list list) =
-	let code = warning_id w in
-	let in_range range = match range with
-		| WRExact i -> i = code
-		| WRRange(i1,i2) -> code >= i1 && code <= i2
+	let rec matches w id =
+		id = w || match (warning_obj w).w_parent with
+			| None -> false
+			| Some w' -> matches w' id
 	in
 	in
 	let rec loop mode l = match l with
 	let rec loop mode l = match l with
 		| [] ->
 		| [] ->
@@ -135,7 +87,7 @@ let get_mode w (l : warning_option list list) =
 				| [] ->
 				| [] ->
 					mode
 					mode
 				| opt :: l ->
 				| opt :: l ->
-					let mode = if in_range opt.wo_range then opt.wo_mode else mode in
+					let mode = if matches w opt.wo_warning then opt.wo_mode else mode in
 					loop2 mode l
 					loop2 mode l
 			in
 			in
 			loop (loop2 mode l2) l
 			loop (loop2 mode l2) l

+ 2 - 2
src/optimization/analyzerConfig.ml

@@ -100,13 +100,13 @@ let update_config_from_meta com config ml =
 						| "as_var" -> config
 						| "as_var" -> config
 						| _ ->
 						| _ ->
 							let options = Warning.from_meta ml in
 							let options = Warning.from_meta ml in
-							com.warning WAnalyzer options (StringError.string_error s all_flags ("Unrecognized analyzer option: " ^ s)) (pos e);
+							com.warning WOptimizer options (StringError.string_error s all_flags ("Unrecognized analyzer option: " ^ s)) (pos e);
 							config
 							config
 					end
 					end
 				| _ ->
 				| _ ->
 					let s = Ast.Printer.s_expr e in
 					let s = Ast.Printer.s_expr e in
 					let options = Warning.from_meta ml in
 					let options = Warning.from_meta ml in
-					com.warning WAnalyzer options (StringError.string_error s all_flags ("Unrecognized analyzer option: " ^ s)) (pos e);
+					com.warning WOptimizer options (StringError.string_error s all_flags ("Unrecognized analyzer option: " ^ s)) (pos e);
 					config
 					config
 			) config el
 			) config el
 		| (Meta.HasUntyped,_,_) ->
 		| (Meta.HasUntyped,_,_) ->

+ 1 - 1
src/optimization/inlineConstructors.ml

@@ -317,7 +317,7 @@ let inline_constructors ctx original_e =
 						if is_lvalue && iv_is_const fiv then raise Not_found;
 						if is_lvalue && iv_is_const fiv then raise Not_found;
 						if fiv.iv_closed then raise Not_found;
 						if fiv.iv_closed then raise Not_found;
 						if not is_lvalue && fiv.iv_state == IVSUnassigned then (
 						if not is_lvalue && fiv.iv_state == IVSUnassigned then (
-							warning ctx WInliner ("Constructor inlining cancelled because of use of uninitialized member field " ^ fname) ethis.epos;
+							warning ctx WConstructorInliningCancelled ("Constructor inlining cancelled because of use of uninitialized member field " ^ fname) ethis.epos;
 							raise Not_found
 							raise Not_found
 						);
 						);
 						if not captured then cancel_iv fiv efield.epos;
 						if not captured then cancel_iv fiv efield.epos;

+ 4 - 4
src/typing/matcher.ml

@@ -252,7 +252,7 @@ module Pattern = struct
 								| _ -> ""
 								| _ -> ""
 							in
 							in
 							let fields = List.map (fun (el) -> tpath ^ el) l in
 							let fields = List.map (fun (el) -> tpath ^ el) l in
-							warning pctx.ctx WMatcher ("Potential typo detected (expected similar values are " ^ (String.concat ", " fields) ^ ")") p
+							warning pctx.ctx WTyper ("Potential typo detected (expected similar values are " ^ (String.concat ", " fields) ^ ")") p
 					end;
 					end;
 					raise (Bad_pattern "Only inline or read-only (default, never) fields can be used as a pattern")
 					raise (Bad_pattern "Only inline or read-only (default, never) fields can be used as a pattern")
 				| TTypeExpr mt ->
 				| TTypeExpr mt ->
@@ -321,7 +321,7 @@ module Pattern = struct
 							()
 							()
 							(* if toplevel then
 							(* if toplevel then
 								warning pctx.ctx (Printf.sprintf "`case %s` has been deprecated, use `case var %s` instead" s s) p *)
 								warning pctx.ctx (Printf.sprintf "`case %s` has been deprecated, use `case var %s` instead" s s) p *)
-						| l -> warning pctx.ctx WMatcher ("Potential typo detected (expected similar values are " ^ (String.concat ", " l) ^ "). Consider using `var " ^ s ^ "` instead") p
+						| l -> warning pctx.ctx WTyper ("Potential typo detected (expected similar values are " ^ (String.concat ", " l) ^ "). Consider using `var " ^ s ^ "` instead") p
 					end;
 					end;
 					let v = add_local false s p in
 					let v = add_local false s p in
 					PatVariable v
 					PatVariable v
@@ -935,8 +935,8 @@ module Useless = struct
 	let check_case ctx p (case,bindings,patterns) =
 	let check_case ctx p (case,bindings,patterns) =
 		let p = List.map (fun (_,_,patterns) -> patterns) p in
 		let p = List.map (fun (_,_,patterns) -> patterns) p in
 		match u' p (copy p) (copy p) patterns [] [] with
 		match u' p (copy p) (copy p) patterns [] [] with
-			| False -> Typecore.warning ctx WMatcher "This case is unused" case.case_pos
-			| Pos p -> Typecore.warning ctx WMatcher "This pattern is unused" p
+			| False -> Typecore.warning ctx WUnusedPattern "This case is unused" case.case_pos
+			| Pos p -> Typecore.warning ctx WUnusedPattern "This pattern is unused" p
 			| True -> ()
 			| True -> ()
 
 
 	let check ctx cases =
 	let check ctx cases =

+ 1 - 1
src/typing/typeloadFields.ml

@@ -1400,7 +1400,7 @@ let create_method (ctx,cctx,fctx) c f fd p =
 			delay ctx PTypeField (fun () -> args#verify_extern);
 			delay ctx PTypeField (fun () -> args#verify_extern);
 		if fd.f_expr <> None then begin
 		if fd.f_expr <> None then begin
 			if fctx.is_abstract then display_error ctx.com "Abstract methods may not have an expression" p
 			if fctx.is_abstract then display_error ctx.com "Abstract methods may not have an expression" p
-			else if not (fctx.is_inline || fctx.is_macro) then warning ctx WExternInit "Extern non-inline function may not have an expression" p;
+			else if not (fctx.is_inline || fctx.is_macro) then warning ctx WExternWithExpr "Extern non-inline function may not have an expression" p;
 		end;
 		end;
 	end;
 	end;
 	cf
 	cf

+ 1 - 1
tests/misc/projects/Issue10184/check-warning.hxml.stderr

@@ -1 +1 @@
-Deprecated.hx:3: characters 2-8 : Warning : Std.is is deprecated. Use Std.isOfType instead.
+Deprecated.hx:3: characters 2-8 : Warning : (WDeprecated) Std.is is deprecated. Use Std.isOfType instead.

+ 10 - 10
tests/misc/projects/Issue2508/compile.hxml.stderr

@@ -1,10 +1,10 @@
-Main.hx:15: characters 4-15 : Warning : This case is unused
-Main.hx:20: characters 4-14 : Warning : This case is unused
-Main.hx:21: characters 4-15 : Warning : This case is unused
-Main.hx:26: characters 6-11 : Warning : This pattern is unused
-Main.hx:32: characters 7-18 : Warning : This pattern is unused
-Main.hx:44: characters 4-32 : Warning : This case is unused
-Main.hx:50: characters 4-19 : Warning : This case is unused
-Main.hx:55: characters 4-15 : Warning : This case is unused
-Main.hx:60: characters 4-16 : Warning : This case is unused
-Main.hx:66: characters 9-15 : Warning : This pattern is unused
+Main.hx:15: characters 4-15 : Warning : (WUnusedPattern) This case is unused
+Main.hx:20: characters 4-14 : Warning : (WUnusedPattern) This case is unused
+Main.hx:21: characters 4-15 : Warning : (WUnusedPattern) This case is unused
+Main.hx:26: characters 6-11 : Warning : (WUnusedPattern) This pattern is unused
+Main.hx:32: characters 7-18 : Warning : (WUnusedPattern) This pattern is unused
+Main.hx:44: characters 4-32 : Warning : (WUnusedPattern) This case is unused
+Main.hx:50: characters 4-19 : Warning : (WUnusedPattern) This case is unused
+Main.hx:55: characters 4-15 : Warning : (WUnusedPattern) This case is unused
+Main.hx:60: characters 4-16 : Warning : (WUnusedPattern) This case is unused
+Main.hx:66: characters 9-15 : Warning : (WUnusedPattern) This pattern is unused

+ 24 - 24
tests/misc/projects/Issue4720/compile.hxml.stderr

@@ -1,24 +1,24 @@
-Main.hx:8: characters 9-15 : Warning : Usage of this typedef is deprecated
-Main.hx:9: characters 9-19 : Warning : Usage of this typedef is deprecated
-Main.hx:10: characters 9-14 : Warning : Usage of this typedef is deprecated
-Main.hx:18: characters 13-19 : Warning : This typedef is deprecated in favor of MyClass
-Main.hx:19: characters 9-14 : Warning : Usage of this typedef is deprecated
-Main.hx:20: characters 13-22 : Warning : This typedef is deprecated in favor of MyAbstract
-Main.hx:32: characters 9-13 : Warning : Usage of this enum is deprecated
-Main.hx:36: characters 9-14 : Warning : Usage of this enum field is deprecated
-Main.hx:4: characters 9-16 : Warning : Usage of this class is deprecated
-Main.hx:5: characters 9-20 : Warning : Usage of this class is deprecated
-Main.hx:6: characters 9-15 : Warning : Usage of this enum is deprecated
-Main.hx:15: characters 9-22 : Warning : Usage of this class is deprecated
-Main.hx:16: characters 9-15 : Warning : Usage of this enum is deprecated
-Main.hx:17: characters 9-29 : Warning : Usage of this class is deprecated
-Main.hx:18: characters 9-21 : Warning : Usage of this class is deprecated
-Main.hx:20: characters 9-28 : Warning : Usage of this class is deprecated
-Main.hx:23: characters 9-24 : Warning : Usage of this field is deprecated
-Main.hx:24: characters 9-23 : Warning : Usage of this field is deprecated
-Main.hx:25: characters 9-27 : Warning : Usage of this field is deprecated
-Main.hx:26: characters 17-35 : Warning : Usage of this field is deprecated
-Main.hx:27: characters 9-25 : Warning : Usage of this field is deprecated
-Main.hx:28: characters 17-33 : Warning : Usage of this field is deprecated
-Main.hx:31: characters 11-15 : Warning : Usage of this enum is deprecated
-Main.hx:35: characters 11-16 : Warning : Usage of this enum field is deprecated
+Main.hx:8: characters 9-15 : Warning : (WDeprecated) Usage of this typedef is deprecated
+Main.hx:9: characters 9-19 : Warning : (WDeprecated) Usage of this typedef is deprecated
+Main.hx:10: characters 9-14 : Warning : (WDeprecated) Usage of this typedef is deprecated
+Main.hx:18: characters 13-19 : Warning : (WDeprecated) This typedef is deprecated in favor of MyClass
+Main.hx:19: characters 9-14 : Warning : (WDeprecated) Usage of this typedef is deprecated
+Main.hx:20: characters 13-22 : Warning : (WDeprecated) This typedef is deprecated in favor of MyAbstract
+Main.hx:32: characters 9-13 : Warning : (WDeprecated) Usage of this enum is deprecated
+Main.hx:36: characters 9-14 : Warning : (WDeprecated) Usage of this enum field is deprecated
+Main.hx:4: characters 9-16 : Warning : (WDeprecated) Usage of this class is deprecated
+Main.hx:5: characters 9-20 : Warning : (WDeprecated) Usage of this class is deprecated
+Main.hx:6: characters 9-15 : Warning : (WDeprecated) Usage of this enum is deprecated
+Main.hx:15: characters 9-22 : Warning : (WDeprecated) Usage of this class is deprecated
+Main.hx:16: characters 9-15 : Warning : (WDeprecated) Usage of this enum is deprecated
+Main.hx:17: characters 9-29 : Warning : (WDeprecated) Usage of this class is deprecated
+Main.hx:18: characters 9-21 : Warning : (WDeprecated) Usage of this class is deprecated
+Main.hx:20: characters 9-28 : Warning : (WDeprecated) Usage of this class is deprecated
+Main.hx:23: characters 9-24 : Warning : (WDeprecated) Usage of this field is deprecated
+Main.hx:24: characters 9-23 : Warning : (WDeprecated) Usage of this field is deprecated
+Main.hx:25: characters 9-27 : Warning : (WDeprecated) Usage of this field is deprecated
+Main.hx:26: characters 17-35 : Warning : (WDeprecated) Usage of this field is deprecated
+Main.hx:27: characters 9-25 : Warning : (WDeprecated) Usage of this field is deprecated
+Main.hx:28: characters 17-33 : Warning : (WDeprecated) Usage of this field is deprecated
+Main.hx:31: characters 11-15 : Warning : (WDeprecated) Usage of this enum is deprecated
+Main.hx:35: characters 11-16 : Warning : (WDeprecated) Usage of this enum field is deprecated

+ 1 - 1
tests/misc/projects/Issue6226/compile.hxml.stderr

@@ -1 +1 @@
-Main.hx:7: characters 3-4 : Warning : Usage of this field is deprecated
+Main.hx:7: characters 3-4 : Warning : (WDeprecated) Usage of this field is deprecated

+ 1 - 1
tests/misc/projects/Issue7096/compile.hxml.stderr

@@ -1 +1 @@
-Main.hx:5: characters 9-10 : Warning : Usage of this field is deprecated
+Main.hx:5: characters 9-10 : Warning : (WDeprecated) Usage of this field is deprecated

+ 2 - 2
tests/misc/projects/Issue7447/compile.hxml.stderr

@@ -1,2 +1,2 @@
-Main.hx:4: characters 15-16 : Warning : Local variable v might be used before being initialized
-Main.hx:10: characters 15-19 : Warning : this might be used before assigning a value to it
+Main.hx:4: characters 15-16 : Warning : (WVarInit) Local variable v might be used before being initialized
+Main.hx:10: characters 15-19 : Warning : (WVarInit) this might be used before assigning a value to it

+ 1 - 1
tests/misc/projects/Issue7669/compile-fail.hxml.stderr

@@ -1,5 +1,5 @@
 Main.hx:4: characters 9-23 : Unknown identifier : NumpadSubtract, pattern variables must be lower-case or with `var ` prefix
 Main.hx:4: characters 9-23 : Unknown identifier : NumpadSubtract, pattern variables must be lower-case or with `var ` prefix
 Main.hx:5: characters 9-22 : Unknown identifier : NumpadDecimal, pattern variables must be lower-case or with `var ` prefix
 Main.hx:5: characters 9-22 : Unknown identifier : NumpadDecimal, pattern variables must be lower-case or with `var ` prefix
-Main.hx:5: characters 4-23 : Warning : This case is unused
+Main.hx:5: characters 4-23 : Warning : (WUnusedPattern) This case is unused
 Main.hx:8: characters 15-29 : Unknown identifier : NumpadSubtract, pattern variables must be lower-case or with `var ` prefix
 Main.hx:8: characters 15-29 : Unknown identifier : NumpadSubtract, pattern variables must be lower-case or with `var ` prefix
 Main.hx:8: characters 15-29 : Variable NumpadSubtract must appear exactly once in each sub-pattern
 Main.hx:8: characters 15-29 : Variable NumpadSubtract must appear exactly once in each sub-pattern

+ 1 - 1
tests/misc/projects/Issue8471/compile2.hxml.stderr

@@ -1,4 +1,4 @@
-Macro2.hx:12: characters 25-39 : Warning : This typedef is deprecated in favor of String
+Macro2.hx:12: characters 25-39 : Warning : (WDeprecated) This typedef is deprecated in favor of String
 Warning : 1
 Warning : 1
 Warning : 2
 Warning : 2
 Warning : 3
 Warning : 3

+ 1 - 1
tests/misc/projects/Issue9192/compile.hxml.stderr

@@ -1 +1 @@
-Main.hx:3: characters 3-4 : Warning : Usage of this class is deprecated
+Main.hx:3: characters 3-4 : Warning : (WDeprecated) Usage of this class is deprecated

+ 1 - 1
tests/misc/projects/Issue9204/compile.hxml.stderr

@@ -1 +1 @@
-Main.hx:7: characters 9-13 : Warning : Usage of this field is deprecated
+Main.hx:7: characters 9-13 : Warning : (WDeprecated) Usage of this field is deprecated

+ 1 - 1
tests/misc/projects/Issue9425/compile-success.hxml.stderr

@@ -1 +1 @@
-Main.hx:10: characters 3-14 : Warning : Usage of this field is deprecated
+Main.hx:10: characters 3-14 : Warning : (WDeprecated) Usage of this field is deprecated

+ 1 - 2
tests/unit/compile-each.hxml

@@ -9,5 +9,4 @@
 --dce full
 --dce full
 -lib utest:git:https://github.com/haxe-utest/utest#559b24c9a36533281ba7a2eed8aab83ed6b872b4
 -lib utest:git:https://github.com/haxe-utest/utest#559b24c9a36533281ba7a2eed8aab83ed6b872b4
 -D analyzer-optimize
 -D analyzer-optimize
--D analyzer-user-var-fusion
--w -400-102
+-D analyzer-user-var-fusion

+ 2 - 2
tests/unit/src/unit/TestGADT.hx

@@ -42,7 +42,7 @@ class TestGADT extends Test {
 		eq(s, true);
 		eq(s, true);
 	}
 	}
 
 
-	@:haxe.warning("-600")
+	@:haxe.warning("-WGenerator")
 	static function evalConst<T>(c:Constant<T>):T {
 	static function evalConst<T>(c:Constant<T>):T {
 		return switch (c) {
 		return switch (c) {
 			case CString(s): s;
 			case CString(s): s;
@@ -51,7 +51,7 @@ class TestGADT extends Test {
 		}
 		}
 	}
 	}
 
 
-	@:haxe.warning("-600")
+	@:haxe.warning("-WGenerator")
 	static function evalBinop<T, C>(op:Binop<C, T>, e1:Expr<C>, e2:Expr<C>):T {
 	static function evalBinop<T, C>(op:Binop<C, T>, e1:Expr<C>, e2:Expr<C>):T {
 		return switch (op) {
 		return switch (op) {
 			case OpAdd: eval(e1) + eval(e2);
 			case OpAdd: eval(e1) + eval(e2);

+ 12 - 7
tests/unit/src/unit/TestGeneric.hx

@@ -8,6 +8,7 @@ private typedef MyAnon = {
 @:generic
 @:generic
 class MyGeneric<T> {
 class MyGeneric<T> {
 	public var t:T;
 	public var t:T;
+
 	public function new(t:T) {
 	public function new(t:T) {
 		this.t = t;
 		this.t = t;
 	}
 	}
@@ -15,25 +16,28 @@ class MyGeneric<T> {
 
 
 class MyRandomClass {
 class MyRandomClass {
 	public var s:String;
 	public var s:String;
+
 	public function new(s:String) {
 	public function new(s:String) {
 		this.s = s;
 		this.s = s;
 	}
 	}
 }
 }
 
 
-class MyRandomEmptyClass { }
+class MyRandomEmptyClass {}
 
 
 @:generic class RBNode<T:RBNode<T>> {
 @:generic class RBNode<T:RBNode<T>> {
-	public var rbLeft : T;
-	public var rbRight : T;
+	public var rbLeft:T;
+	public var rbRight:T;
 }
 }
 
 
 @:generic class RBTree<T:RBNode<T>> {
 @:generic class RBTree<T:RBNode<T>> {
-	public var root : T;
-	public function new() {	}
+	public var root:T;
+
+	public function new() {}
 }
 }
 
 
 class MyData extends RBNode<MyData> {
 class MyData extends RBNode<MyData> {
-	var id : Int;
+	var id:Int;
+
 	public function new(id:Int) {
 	public function new(id:Int) {
 		this.id = id;
 		this.id = id;
 	}
 	}
@@ -46,7 +50,7 @@ class TestGeneric extends Test {
 		t((mg.t is Int));
 		t((mg.t is Int));
 
 
 		var mg = new MyGeneric<String>("12");
 		var mg = new MyGeneric<String>("12");
-		eq(mg.t,"12");
+		eq(mg.t, "12");
 		t((mg.t is String));
 		t((mg.t is String));
 	}
 	}
 
 
@@ -64,6 +68,7 @@ class TestGeneric extends Test {
 		eq(a.t.b, null);
 		eq(a.t.b, null);
 	}
 	}
 
 
+	@:haxe.warning("-WGenerator")
 	function testGenericFn() {
 	function testGenericFn() {
 		var a = new MyGeneric<Int->Int>(function(i:Int):Int return i * i);
 		var a = new MyGeneric<Int->Int>(function(i:Int):Int return i * i);
 		eq(4, a.t(2));
 		eq(4, a.t(2));

+ 13 - 10
tests/unit/src/unit/TestRest.hx

@@ -20,7 +20,7 @@ class TestRest extends Test {
 	function testToArray() {
 	function testToArray() {
 		function rest(...r:Int):Array<Int> {
 		function rest(...r:Int):Array<Int> {
 			var a = r.toArray();
 			var a = r.toArray();
-			a[0] = 999; //make sure array modification doesn't affect rest arguments object
+			a[0] = 999; // make sure array modification doesn't affect rest arguments object
 			return r.toArray();
 			return r.toArray();
 		}
 		}
 		aeq([1, 2, 3, 4], rest(1, 2, 3, 4));
 		aeq([1, 2, 3, 4], rest(1, 2, 3, 4));
@@ -36,7 +36,7 @@ class TestRest extends Test {
 
 
 	function testIterator() {
 	function testIterator() {
 		function rest(...r:Int):Array<Int> {
 		function rest(...r:Int):Array<Int> {
-			return [for(i in r) i];
+			return [for (i in r) i];
 		}
 		}
 		aeq([3, 2, 1], rest(3, 2, 1));
 		aeq([3, 2, 1], rest(3, 2, 1));
 	}
 	}
@@ -45,11 +45,11 @@ class TestRest extends Test {
 		function rest(...r:Int):{keys:Array<Int>, values:Array<Int>} {
 		function rest(...r:Int):{keys:Array<Int>, values:Array<Int>} {
 			var keys = [];
 			var keys = [];
 			var values = [];
 			var values = [];
-			for(k => v in r) {
+			for (k => v in r) {
 				keys.push(k);
 				keys.push(k);
 				values.push(v);
 				values.push(v);
 			}
 			}
-			return {keys:keys, values:values}
+			return {keys: keys, values: values}
 		}
 		}
 		var r = rest(3, 2, 1, 0);
 		var r = rest(3, 2, 1, 0);
 		aeq([0, 1, 2, 3], r.keys);
 		aeq([0, 1, 2, 3], r.keys);
@@ -57,10 +57,11 @@ class TestRest extends Test {
 	}
 	}
 
 
 	@:depends(testToArray)
 	@:depends(testToArray)
+	@:haxe.warning("-WGenerator")
 	function testAppend() {
 	function testAppend() {
 		function rest(...r:Int) {
 		function rest(...r:Int) {
 			var appended = r.append(9);
 			var appended = r.append(9);
-			return {initial:r.toArray(), appended:appended.toArray()}
+			return {initial: r.toArray(), appended: appended.toArray()}
 		}
 		}
 		var result = rest(1, 2);
 		var result = rest(1, 2);
 		aeq([1, 2], result.initial);
 		aeq([1, 2], result.initial);
@@ -71,7 +72,7 @@ class TestRest extends Test {
 	function testPrepend() {
 	function testPrepend() {
 		function rest(...r:Int) {
 		function rest(...r:Int) {
 			var prepended = r.prepend(9);
 			var prepended = r.prepend(9);
-			return {initial:r.toArray(), prepended:prepended.toArray()}
+			return {initial: r.toArray(), prepended: prepended.toArray()}
 		}
 		}
 		var result = rest(1, 2);
 		var result = rest(1, 2);
 		aeq([1, 2], result.initial);
 		aeq([1, 2], result.initial);
@@ -112,7 +113,7 @@ class TestRest extends Test {
 
 
 	@:depends(testToArray)
 	@:depends(testToArray)
 	function testClosure() {
 	function testClosure() {
-		var fn:(...r:Int)->Array<Int>;
+		var fn:(...r:Int) -> Array<Int>;
 		fn = staticRest;
 		fn = staticRest;
 		aeq([1, 2, 3], fn(1, 2, 3));
 		aeq([1, 2, 3], fn(1, 2, 3));
 		aeq([1, 2, 3], fn(...[1, 2, 3]));
 		aeq([1, 2, 3], fn(...[1, 2, 3]));
@@ -120,9 +121,11 @@ class TestRest extends Test {
 		aeq([3, 2, 1], fn(3, 2, 1));
 		aeq([3, 2, 1], fn(3, 2, 1));
 		aeq([3, 2, 1], fn(...[3, 2, 1]));
 		aeq([3, 2, 1], fn(...[3, 2, 1]));
 	}
 	}
+
 	function instanceRest(...r:Int):Array<Int> {
 	function instanceRest(...r:Int):Array<Int> {
 		return r.toArray();
 		return r.toArray();
 	}
 	}
+
 	static function staticRest(...r:Int):Array<Int> {
 	static function staticRest(...r:Int):Array<Int> {
 		return r.toArray();
 		return r.toArray();
 	}
 	}
@@ -140,14 +143,14 @@ class TestRest extends Test {
 		function rest(...r:{f:Int}) {
 		function rest(...r:{f:Int}) {
 			return r.toArray();
 			return r.toArray();
 		}
 		}
-		aeq([{f:2}, {f:1}], rest({f:2}, {f:1}));
+		aeq([{f: 2}, {f: 1}], rest({f: 2}, {f: 1}));
 	}
 	}
 
 
 	function testInferred() {
 	function testInferred() {
 		function rest(...r) {
 		function rest(...r) {
 			(r[0] : Int);
 			(r[0] : Int);
 		}
 		}
-		HelperMacros.typedAs(rest, (null : (r : Rest<Int>)->Void));
+		HelperMacros.typedAs(rest, (null : (r:Rest<Int>) -> Void));
 	}
 	}
 
 
 	function testToString() {
 	function testToString() {
@@ -178,4 +181,4 @@ private class Child extends Parent {
 	override public function methodWithRest(rest:Rest<Int>):Rest<Int> {
 	override public function methodWithRest(rest:Rest<Int>):Rest<Int> {
 		return super.methodWithRest(...rest.append(999));
 		return super.methodWithRest(...rest.append(999));
 	}
 	}
-}
+}

+ 58 - 50
tests/unit/src/unit/UnitBuilder.hx

@@ -25,10 +25,10 @@ package unit;
 import haxe.macro.Context;
 import haxe.macro.Context;
 import haxe.macro.Expr;
 import haxe.macro.Expr;
 import haxe.macro.Type;
 import haxe.macro.Type;
+
 using StringTools;
 using StringTools;
 
 
 class UnitBuilder {
 class UnitBuilder {
-
 	static public macro function generateSpec(basePath:String) {
 	static public macro function generateSpec(basePath:String) {
 		var ret = [];
 		var ret = [];
 		var numFiles = 0;
 		var numFiles = 0;
@@ -46,34 +46,43 @@ class UnitBuilder {
 						params: [],
 						params: [],
 						expr: read(filePath)
 						expr: read(filePath)
 					}
 					}
-					var p = Context.makePosition( { min:0, max:0, file:filePath + file } );
+					var p = Context.makePosition({min: 0, max: 0, file: filePath + file});
 					var field = {
 					var field = {
 						name: "test",
 						name: "test",
 						kind: FFun(func),
 						kind: FFun(func),
 						pos: p,
 						pos: p,
 						access: [APublic],
 						access: [APublic],
 						doc: null,
 						doc: null,
-						meta: []
+						meta: file.endsWith("Utf8.unit.hx") ? [{name: ":haxe.warning", params: [macro "-WDeprecated"], pos: p}] : []
 					};
 					};
 					var pack = ["unit", "spec"].concat(pack);
 					var pack = ["unit", "spec"].concat(pack);
 					var typeName = "Test" + file.substr(0, file.indexOf("."));
 					var typeName = "Test" + file.substr(0, file.indexOf("."));
-					Context.defineModule(pack.join(".") + "." + typeName, [{
-						pack: pack,
-						name: typeName,
-						pos: p,
-						kind: TDClass({
-							pack: ["unit"],
-							name: "Test"
-						}),
-						fields: [field]
-					}], [{
-						path: [{pos: p, name: "unit"}, {pos: p, name: "spec"}, {pos: p, name: "TestSpecification"}],
-						mode: INormal
-					}, {
-						// TODO: import.hx doesn't work for this?
-						path: [{pos: p, name: "haxe"}, {pos: p, name: "macro"}, {pos: p, name: "Expr"}],
-						mode: INormal
-					}]);
+					Context.defineModule(pack.join(".") + "." + typeName, [
+						{
+							pack: pack,
+							name: typeName,
+							pos: p,
+							kind: TDClass({
+								pack: ["unit"],
+								name: "Test"
+							}),
+							fields: [field]
+						}
+					], [
+						{
+							path: [
+								{pos: p, name: "unit"},
+								{pos: p, name: "spec"},
+								{pos: p, name: "TestSpecification"}
+							],
+							mode: INormal
+						},
+						{
+							// TODO: import.hx doesn't work for this?
+							path: [{pos: p, name: "haxe"}, {pos: p, name: "macro"}, {pos: p, name: "Expr"}],
+							mode: INormal
+						}
+					]);
 					var tp:TypePath = {
 					var tp:TypePath = {
 						pack: pack,
 						pack: pack,
 						name: typeName
 						name: typeName
@@ -81,7 +90,7 @@ class UnitBuilder {
 					ret.push(macro new $tp());
 					ret.push(macro new $tp());
 				} else if (sys.FileSystem.isDirectory(filePath)) {
 				} else if (sys.FileSystem.isDirectory(filePath)) {
 					readDir(filePath, pack.concat([file]));
 					readDir(filePath, pack.concat([file]));
-				} else if(filePath.endsWith('.hx')) {
+				} else if (filePath.endsWith('.hx')) {
 					Context.error('$filePath: specification tests filenames should end with ".unit.hx"', Context.currentPos());
 					Context.error('$filePath: specification tests filenames should end with ".unit.hx"', Context.currentPos());
 				}
 				}
 			}
 			}
@@ -93,28 +102,32 @@ class UnitBuilder {
 
 
 	#if macro
 	#if macro
 	static function collapseToOrExpr(el:Array<Expr>) {
 	static function collapseToOrExpr(el:Array<Expr>) {
-		return switch(el) {
+		return switch (el) {
 			case []: throw "";
 			case []: throw "";
 			case [e]: e;
 			case [e]: e;
-		case _:
-			var e = el.pop();
-			{ expr: EBinop(OpBoolOr, e, collapseToOrExpr(el)), pos: e.pos }
+			case _:
+				var e = el.pop();
+				{expr: EBinop(OpBoolOr, e, collapseToOrExpr(el)), pos: e.pos}
 		}
 		}
 	}
 	}
 
 
 	static function mkEq(e1, e2, p:Position) {
 	static function mkEq(e1, e2, p:Position) {
 		function isFloat(e) {
 		function isFloat(e) {
-			try return switch(Context.follow(Context.typeof(e))) {
-				case TAbstract(tr, _):
-					tr.get().name == "Float";
-				case _:
-					false;
-			} catch (e:Dynamic) {
+			try
+				return switch (Context.follow(Context.typeof(e))) {
+					case TAbstract(tr, _):
+						tr.get().name == "Float";
+					case _:
+						false;
+				} catch (e:Dynamic) {
 				return false;
 				return false;
 			}
 			}
 		}
 		}
 		var e = switch [isFloat(e1) || isFloat(e2), e2.expr] {
 		var e = switch [isFloat(e1) || isFloat(e2), e2.expr] {
-			case [_, EField( { expr:EConst(CIdent("Math" | "math")) }, "POSITIVE_INFINITY" | "NEGATIVE_INFINITY")] if (Context.defined("cpp") || Context.defined("php")):
+			case [
+				_,
+				EField({expr: EConst(CIdent("Math" | "math"))}, "POSITIVE_INFINITY" | "NEGATIVE_INFINITY")
+			] if (Context.defined("cpp") || Context.defined("php")):
 				macro t($e1 == $e2);
 				macro t($e1 == $e2);
 			case [true, _]:
 			case [true, _]:
 				macro feq($e1, $e2);
 				macro feq($e1, $e2);
@@ -126,12 +139,13 @@ class UnitBuilder {
 			pos: p
 			pos: p
 		}
 		}
 	}
 	}
+
 	static public function read(path:String) {
 	static public function read(path:String) {
-		var p = Context.makePosition( { min:0, max:0, file:path } );
+		var p = Context.makePosition({min: 0, max: 0, file: path});
 		var file = sys.io.File.getContent(path);
 		var file = sys.io.File.getContent(path);
 		var code = Context.parseInlineString("{" + file + "\n}", p);
 		var code = Context.parseInlineString("{" + file + "\n}", p);
 		function mkBlock(e:Expr) {
 		function mkBlock(e:Expr) {
-			return switch(e.expr) {
+			return switch (e.expr) {
 				case EBlock(b): b;
 				case EBlock(b): b;
 				case _: [e];
 				case _: [e];
 			}
 			}
@@ -139,30 +153,24 @@ class UnitBuilder {
 		function bl(block:Array<Expr>):Array<Expr> {
 		function bl(block:Array<Expr>):Array<Expr> {
 			var ret = [];
 			var ret = [];
 			for (e in block) {
 			for (e in block) {
-				var e = switch(e.expr) {
-					case EBinop(OpEq, e1, { expr: EConst(CIdent("false")) } )
-					| EBinop(OpEq, { expr: EConst(CIdent("false")) }, e1):
+				var e = switch (e.expr) {
+					case EBinop(OpEq, e1, {expr: EConst(CIdent("false"))}) | EBinop(OpEq, {expr: EConst(CIdent("false"))}, e1):
 						{
 						{
 							expr: (macro f($e1)).expr,
 							expr: (macro f($e1)).expr,
 							pos: e.pos
 							pos: e.pos
 						}
 						}
-					case EBinop(OpEq, e1, { expr: EConst(CIdent("true")) } )
-					| EBinop(OpEq, { expr: EConst(CIdent("true")) }, e1):
+					case EBinop(OpEq, e1, {expr: EConst(CIdent("true"))}) | EBinop(OpEq, {expr: EConst(CIdent("true"))}, e1):
 						{
 						{
 							expr: (macro t($e1)).expr,
 							expr: (macro t($e1)).expr,
 							pos: e.pos
 							pos: e.pos
 						}
 						}
-					case EBinop(OpEq, e1, { expr: EArrayDecl(el) } )
-					| EBinop(OpEq, { expr: EArrayDecl(el) }, e1 ):
+					case EBinop(OpEq, e1, {expr: EArrayDecl(el)}) | EBinop(OpEq, {expr: EArrayDecl(el)}, e1):
 						var el2 = [];
 						var el2 = [];
 						for (i in 0...el.length) {
 						for (i in 0...el.length) {
 							var e2 = el[i];
 							var e2 = el[i];
 							el2.push(mkEq((macro $e1[$v{i}]), e2, e.pos));
 							el2.push(mkEq((macro $e1[$v{i}]), e2, e.pos));
 						}
 						}
-						if (el2.length == 0)
-							mkEq((macro @:pos(e1.pos) $e1.length), (macro 0), e.pos);
-						else
-							macro { $a{el2}; };
+						if (el2.length == 0) mkEq((macro @:pos(e1.pos) $e1.length), (macro 0), e.pos); else macro {$a{el2};};
 					case EBinop(OpEq, e1, e2):
 					case EBinop(OpEq, e1, e2):
 						mkEq(e1, e2, e.pos);
 						mkEq(e1, e2, e.pos);
 					case EBinop(OpNotEq, e1, e2):
 					case EBinop(OpNotEq, e1, e2):
@@ -174,18 +182,18 @@ class UnitBuilder {
 						}
 						}
 					case EThrow(e):
 					case EThrow(e):
 						macro exc(function() $e);
 						macro exc(function() $e);
-					case EBinop(OpIn, e1, {expr:EArrayDecl(el) }):
+					case EBinop(OpIn, e1, {expr: EArrayDecl(el)}):
 						var el2 = [];
 						var el2 = [];
 						for (e in el)
 						for (e in el)
 							el2.push(macro $e1 == $e);
 							el2.push(macro $e1 == $e);
-						macro @:pos(e.pos) t(${ collapseToOrExpr(el2) } );
+						macro @:pos(e.pos) t(${collapseToOrExpr(el2)});
 					case EVars(vl):
 					case EVars(vl):
 						for (v in vl)
 						for (v in vl)
 							if (v.name == "t" || v.name == "f" || v.name == "eq" || v.name == "neq")
 							if (v.name == "t" || v.name == "f" || v.name == "eq" || v.name == "neq")
 								Context.error('${v.name} is reserved for unit testing', e.pos);
 								Context.error('${v.name} is reserved for unit testing', e.pos);
-							e;
+						e;
 					case EFor(it, {expr: EBlock(el), pos: p}):
 					case EFor(it, {expr: EBlock(el), pos: p}):
-						{ expr: EFor(it, {expr:EBlock(bl(el)), pos: p}), pos: e.pos };
+						{expr: EFor(it, {expr: EBlock(bl(el)), pos: p}), pos: e.pos};
 					case _:
 					case _:
 						e;
 						e;
 				}
 				}
@@ -197,4 +205,4 @@ class UnitBuilder {
 		return macro $b{bl(block)};
 		return macro $b{bl(block)};
 	}
 	}
 	#end
 	#end
-}
+}

+ 1 - 1
tests/unit/src/unit/issues/Issue10073.hx

@@ -26,7 +26,7 @@ abstract Bar(Int) from Int {
 }
 }
 #end
 #end
 
 
-@:haxe.warning("-600")
+@:haxe.warning("-WGenerator")
 class Issue10073 extends Test {
 class Issue10073 extends Test {
 	function test() {
 	function test() {
 		var foo:Foo = [];
 		var foo:Foo = [];

+ 1 - 0
tests/unit/src/unit/issues/Issue10304.hx

@@ -24,6 +24,7 @@ private class PairIter<T> {
 }
 }
 
 
 class Issue10304 extends Test {
 class Issue10304 extends Test {
+	@:haxe.warning("-WConstructorInliningCancelled")
 	function test() {
 	function test() {
 		var buf = new StringBuf();
 		var buf = new StringBuf();
 		for (p in new PairIter(["1", "2", "3"])) {
 		for (p in new PairIter(["1", "2", "3"])) {

+ 1 - 1
tests/unit/src/unit/issues/Issue2778.hx

@@ -16,7 +16,7 @@ class Issue2778 extends Test {
 		t(unit.HelperMacros.typeError(sameType(BoolLit(true), IntLit(1))));
 		t(unit.HelperMacros.typeError(sameType(BoolLit(true), IntLit(1))));
 	}
 	}
 
 
-	@:haxe.warning("-600")
+	@:haxe.warning("-WGenerator")
 	static function sameType<S>(o1:E<S>, o2:E<S>):S {
 	static function sameType<S>(o1:E<S>, o2:E<S>):S {
 		return switch [o1, o2] {
 		return switch [o1, o2] {
 			case [BoolLit(b1), BoolLit(b2)]: b1 && b2;
 			case [BoolLit(b1), BoolLit(b2)]: b1 && b2;

+ 2 - 1
tests/unit/src/unit/issues/Issue3861.hx

@@ -1,10 +1,11 @@
 package unit.issues;
 package unit.issues;
 
 
 class Issue3861 extends unit.Test {
 class Issue3861 extends unit.Test {
+	@:haxe.warning("-WVarInit")
 	function test() {
 	function test() {
 		var a;
 		var a;
 		var b = function() return a;
 		var b = function() return a;
 		a = 2;
 		a = 2;
 		eq(2, b());
 		eq(2, b());
 	}
 	}
-}
+}

+ 1 - 1
tests/unit/src/unit/issues/Issue4578.hx

@@ -29,7 +29,7 @@ private class IUnOp<X, Y, S:TList> implements Instr<TCons<X, S>, TCons<Y, S>> {
 	}
 	}
 }
 }
 
 
-@:haxe.warning("-600")
+@:haxe.warning("-WGenerator")
 class Issue4578 extends Test {
 class Issue4578 extends Test {
 	function test() {
 	function test() {
 		var i = new IUnOp(function(x) return x * 2);
 		var i = new IUnOp(function(x) return x * 2);

+ 1 - 1
tests/unit/src/unit/issues/Issue6561.hx

@@ -9,7 +9,7 @@ class Issue6561 extends unit.Test {
 		eq("hello", apply(NotLog("hello")));
 		eq("hello", apply(NotLog("hello")));
 	}
 	}
 
 
-	@:haxe.warning("-600")
+	@:haxe.warning("-WGenerator")
 	static function apply<A>(f:Log<A>):A {
 	static function apply<A>(f:Log<A>):A {
 		return switch f {
 		return switch f {
 			case NotLog(msg):
 			case NotLog(msg):