Skip to content

Commit 3ef0cb4

Browse files
authored
Merge pull request #67 from sipma/jsonserialization
JSON: fix serialization error due to SituatedMsg
2 parents b65c047 + 2deb3ba commit 3ef0cb4

File tree

4 files changed

+34
-7
lines changed

4 files changed

+34
-7
lines changed

chc/app/CHVersion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
chcversion: str = "0.2.0-2026-02-23"
1+
chcversion: str = "0.2.0-2026-02-26"

chc/cmdline/jsonresultutil.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ------------------------------------------------------------------------------
55
# The MIT License (MIT)
66
#
7-
# Copyright (c) 2024 Aarno Labs LLC
7+
# Copyright (c) 2024-2026 Aarno Labs LLC
88
#
99
# Permission is hereby granted, free of charge, to any person obtaining a copy
1010
# of this software and associated documentation files (the "Software"), to deal
@@ -203,12 +203,12 @@ def ppo_to_json_result(po: "CFunctionPO") -> JSONResult:
203203
content["predicate"] = str(po.predicate)
204204
content["context"] = programcontext_to_json_result(po.context).content
205205
if po.is_closed:
206-
content["expl"] = po.explanation
206+
content["expl"] = po.explanation_txt
207207
else:
208208
if po.has_diagnostic():
209-
content["argdiagnostics"] = po.diagnostic.argument_msgs
209+
content["argdiagnostics"] = po.diagnostic.argument_msgs_txt
210210
content["keydiagnostics"] = po.diagnostic.keyword_msgs
211-
content["msgdiagnostics"] = po.diagnostic.msgs
211+
content["msgdiagnostics"] = po.diagnostic.msgs_txt
212212
return JSONResult("ppo", content, "ok")
213213

214214

chc/proof/CFunctionPO.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Copyright (c) 2017-2020 Kestrel Technology LLC
88
# Copyright (c) 2020-2022 Henny B. Sipma
9-
# Copyright (c) 2023-2024 Aarno Labs LLC
9+
# Copyright (c) 2023-2026 Aarno Labs LLC
1010
#
1111
# Permission is hereby granted, free of charge, to any person obtaining a copy
1212
# of this software and associated documentation files (the "Software"), to deal
@@ -185,6 +185,16 @@ def has_dependencies(self) -> bool:
185185
def explanation(self) -> Optional["SituatedMsg"]:
186186
return self._explanation
187187

188+
@property
189+
def explanation_txt(self) -> Optional[str]:
190+
"""Returns the text of the explanation message without the additional
191+
details."""
192+
193+
if self.explanation is not None:
194+
return self.explanation.msg
195+
else:
196+
return None
197+
188198
def has_explanation(self) -> bool:
189199
return self._explanation is not None
190200

chc/proof/CProofDiagnostic.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
# Copyright (c) 2017-2020 Kestrel Technology LLC
88
# Copyright (c) 2020-2022 Henny B. Sipma
9-
# Copyright (c) 2023-2024 Aarno Labs LLC
9+
# Copyright (c) 2023-2026 Aarno Labs LLC
1010
#
1111
# Permission is hereby granted, free of charge, to any person obtaining a copy
1212
# of this software and associated documentation files (the "Software"), to deal
@@ -148,6 +148,13 @@ def msgs(self) -> List[SituatedMsg]:
148148
SituatedMsg(self.cd, x) for x in mnode.findall("msg")]
149149
return self._msgs
150150

151+
@property
152+
def msgs_txt(self) -> List[str]:
153+
"""Returns the ext of the situated msgs without the additional
154+
details."""
155+
156+
return [smsg.msg for smsg in self.msgs]
157+
151158
@property
152159
def argument_msgs(self) -> Dict[int, List[SituatedMsg]]:
153160
"""Returns argument-specific diagnostic messages.
@@ -168,6 +175,16 @@ def argument_msgs(self) -> Dict[int, List[SituatedMsg]]:
168175
self._amsgs[int(xargindex)] = msgs
169176
return self._amsgs
170177

178+
@property
179+
def argument_msgs_txt(self) -> Dict[int, List[str]]:
180+
"""Returns the texts of the situated msgs without the additional
181+
details."""
182+
183+
result: Dict[int, List[str]] = {}
184+
for (index, smsgs) in self.argument_msgs.items():
185+
result[index] = [smsg.msg for smsg in smsgs]
186+
return result
187+
171188
@property
172189
def keyword_msgs(self) -> Dict[str, List[str]]:
173190
"""Returns diagnostics with a known keyword (e.g., a domain name)."""

0 commit comments

Comments
 (0)