From ccd3aa52902948ba9b7d284fcbcf35408b0d209a Mon Sep 17 00:00:00 2001 From: Karoliine Holter Date: Tue, 13 Feb 2024 11:34:53 +0200 Subject: [PATCH 1/2] Use context tags in warnings instead of hash --- src/common/util/messages.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/util/messages.ml b/src/common/util/messages.ml index fe090379a1..fea36d42ff 100644 --- a/src/common/util/messages.ml +++ b/src/common/util/messages.ml @@ -69,7 +69,7 @@ struct let text_with_context {text; context; _} = match context with - | Some context when GobConfig.get_bool "dbg.warn_with_context" -> text ^ " in context " ^ string_of_int (ControlSpecC.hash context) (* TODO: this is kind of useless *) + | Some context when GobConfig.get_bool "dbg.warn_with_context" -> text ^ " in context " ^ string_of_int (ControlSpecC.tag context) (* TODO: this is kind of useless *) | _ -> text end From 5f1e272ee5326e9d11af9ae7681c80424eb76e5d Mon Sep 17 00:00:00 2001 From: Karoliine Holter Date: Thu, 15 Feb 2024 12:59:23 +0200 Subject: [PATCH 2/2] Add context_to_yojson in messages --- src/common/util/messages.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/util/messages.ml b/src/common/util/messages.ml index fea36d42ff..0bc9449dcb 100644 --- a/src/common/util/messages.ml +++ b/src/common/util/messages.ml @@ -61,10 +61,12 @@ end module Piece = struct + let context_to_yojson context = `Assoc [("tag", `Int (ControlSpecC.tag context))] + type t = { loc: Location.t option; (* only *_each warnings have this, used for deduplication *) text: string; - context: (ControlSpecC.t [@of_yojson fun x -> Result.Error "ControlSpecC"]) option; + context: (ControlSpecC.t [@to_yojson context_to_yojson] [@of_yojson fun x -> Result.Error "ControlSpecC"]) option; } [@@deriving eq, ord, hash, yojson] let text_with_context {text; context; _} =