Browse Source

[display] review `dms_display` checks

With diagnostics no longer having `dms_display = true`, we have to check against `dms_kind <> DMNone` instead.
Simon Krajewski 7 years ago
parent
commit
77c8f75f0d

+ 1 - 1
src/compiler/main.ml

@@ -790,7 +790,7 @@ try
 	process_ref := process;
 	process ctx.com.args;
 	process_libs();
-	if com.display.dms_display then begin
+	if com.display.dms_kind <> DMNone then begin
 		com.warning <-
 			if com.display.dms_error_policy = EPCollect then
 				(fun s p -> add_diagnostics_message com s p DisplayTypes.DiagnosticsSeverity.Warning)

+ 1 - 1
src/typing/typeloadCheck.ml

@@ -471,7 +471,7 @@ module Inheritance = struct
 					raise_fields l (if is_extends then CRExtends else CRImplements) p
 				in
 				Some (check_herit t is_extends)
-			with Error(Module_not_found(([],name)),p) when ctx.com.display.dms_display ->
+			with Error(Module_not_found(([],name)),p) when ctx.com.display.dms_kind <> DMNone ->
 				if Diagnostics.is_diagnostics_run p then DisplayToplevel.handle_unresolved_identifier ctx name p true;
 				None
 		) herits in

+ 1 - 1
src/typing/typeloadFields.ml

@@ -636,7 +636,7 @@ let bind_var (ctx,cctx,fctx) cf e =
 					| _ -> !analyzer_run_on_expr_ref ctx.com e
 				in
 				let require_constant_expression e msg =
-					if ctx.com.display.dms_display && ctx.com.display.dms_error_policy <> EPCollect then
+					if ctx.com.display.dms_kind <> DMNone && ctx.com.display.dms_error_policy <> EPCollect then
 						e
 					else match Optimizer.make_constant_expression ctx (maybe_run_analyzer e) with
 					| Some e -> e

+ 1 - 1
src/typing/typeloadFunction.ml

@@ -62,7 +62,7 @@ let type_function_arg_value ctx t c do_display =
 				| TConst c -> Some c
 				| TCast(e,None) -> loop e
 				| _ ->
-					if not ctx.com.display.dms_display || ctx.com.display.dms_inline && ctx.com.display.dms_error_policy = EPCollect then
+					if ctx.com.display.dms_kind = DMNone || ctx.com.display.dms_inline && ctx.com.display.dms_error_policy = EPCollect then
 						display_error ctx "Parameter default value should be constant" p;
 					None
 			in

+ 1 - 1
src/typing/typeloadModule.ml

@@ -851,7 +851,7 @@ let type_types_into_module ctx m tdecls p =
 			wildcard_packages = [];
 			module_imports = [];
 		};
-		is_display_file = (ctx.com.display.dms_display && DisplayPosition.is_display_file m.m_extra.m_file);
+		is_display_file = (ctx.com.display.dms_kind <> DMNone && DisplayPosition.is_display_file m.m_extra.m_file);
 		meta = [];
 		this_stack = [];
 		with_type_stack = [];

+ 1 - 1
src/typing/typer.ml

@@ -1822,7 +1822,7 @@ and type_new ctx path el with_type p =
 		mk (TNew (c,params,el)) t p
 	| _ ->
 		error (s_type (print_context()) t ^ " cannot be constructed") p
-	end with Error(No_constructor _ as err,p) when ctx.com.display.dms_display ->
+	end with Error(No_constructor _ as err,p) when ctx.com.display.dms_kind <> DMNone ->
 		display_error ctx (error_msg err) p;
 		Diagnostics.secure_generated_code ctx (mk (TConst TNull) t p)