Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply @:haxe.warning rules to cached warnings too #11775

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ let handle_cache_bound_objects com cbol =
Hashtbl.replace com.resources name data
| IncludeFile(file,position) ->
com.include_files <- (file,position) :: com.include_files
| Warning(w,msg,p) ->
com.warning w [] msg p
| Warning(w,options,msg,p) ->
com.warning w options msg p
) cbol

(* Adds module [m] and all its dependencies (recursively) from the cache to the current compilation
Expand Down
6 changes: 3 additions & 3 deletions src/context/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ type context = {
mutable error : ?depth:int -> string -> pos -> unit;
mutable error_ext : Error.error -> unit;
mutable info : ?depth:int -> ?from_macro:bool -> string -> pos -> unit;
mutable warning : ?depth:int -> ?from_macro:bool -> warning -> Warning.warning_option list list -> string -> pos -> unit;
mutable warning_options : Warning.warning_option list list;
mutable warning : ?depth:int -> ?from_macro:bool -> warning -> warning_option list list -> string -> pos -> unit;
mutable warning_options : warning_option list list;
mutable get_messages : unit -> compiler_message list;
mutable filter_messages : (compiler_message -> bool) -> unit;
mutable run_command : string -> int;
Expand Down Expand Up @@ -443,7 +443,7 @@ let ignore_error com =
b

let module_warning com m w options msg p =
if com.display.dms_full_typing then DynArray.add m.m_extra.m_cache_bound_objects (Warning(w,msg,p));
if com.display.dms_full_typing then DynArray.add m.m_extra.m_cache_bound_objects (Warning(w,options,msg,p));
com.warning w options msg p

(* Defines *)
Expand Down
8 changes: 3 additions & 5 deletions src/context/display/deprecationCheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ let warned_positions = Hashtbl.create 0
let warn_deprecation dctx s p_usage =
let pkey p = (p.pfile,p.pmin) in
if not (Hashtbl.mem warned_positions (pkey p_usage)) then begin
Hashtbl.add warned_positions (pkey p_usage) (s,p_usage);
if not (is_diagnostics dctx.com) then begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, there's a chance that this was here for a reason, though I can't immediately tell why.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll try to figure out why it was there. I had to remove it, though, otherwise the module could be cached without the warning if cached from diagnostics.. :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This originally came from #8632

let options = Warning.from_meta (dctx.class_meta @ dctx.field_meta) in
module_warning dctx.com dctx.curmod WDeprecated options s p_usage;
end
let options = Warning.from_meta (dctx.class_meta @ dctx.field_meta) in
Hashtbl.add warned_positions (pkey p_usage) (s,p_usage,options);
module_warning dctx.com dctx.curmod WDeprecated options s p_usage;
end

let print_deprecation_message dctx meta s p_usage =
Expand Down
10 changes: 7 additions & 3 deletions src/context/display/diagnosticsPrinter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,13 @@ let json_of_diagnostics com dctx =
(* non-append from here *)
begin match Warning.get_mode WDeprecated com.warning_options with
| WMEnable ->
Hashtbl.iter (fun _ (s,p) ->
let wobj = Warning.warning_obj WDeprecated in
add DKDeprecationWarning p MessageSeverity.Warning (Some wobj.w_name) (JString s);
Hashtbl.iter (fun _ (s,p,options) ->
begin match Warning.get_mode WDeprecated (com.warning_options @ options) with
| WMEnable ->
let wobj = Warning.warning_obj WDeprecated in
add DKDeprecationWarning p MessageSeverity.Warning (Some wobj.w_name) (JString s);
| WMDisable -> ()
end
) DeprecationCheck.warned_positions;
| WMDisable ->
()
Expand Down
11 changes: 10 additions & 1 deletion src/core/tType.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,19 @@ type type_param_host =
| TPHLocal
| TPHUnbound

type warning_mode =
| WMEnable
| WMDisable

type warning_option = {
wo_warning : WarningList.warning;
wo_mode : warning_mode;
}

type cache_bound_object =
| Resource of string * string
| IncludeFile of string * string
| Warning of WarningList.warning * string * pos
| Warning of WarningList.warning * (warning_option list list) * string * pos

type t =
| TMono of tmono
Expand Down
10 changes: 1 addition & 9 deletions src/core/warning.ml
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
open Globals
open Error
open TType
include WarningList

type warning_mode =
| WMEnable
| WMDisable

type warning_option = {
wo_warning : warning;
wo_mode : warning_mode;
}

let parse_options s ps lexbuf =
let fail msg p =
raise_typing_error msg {p with pmin = ps.pmin + p.pmin; pmax = ps.pmin + p.pmax}
Expand Down
Loading