[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pickles: diff: correct handling of boundaries constraint err
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pickles: diff: correct handling of boundaries constraint error |
Date: |
Mon, 11 Apr 2022 00:59:21 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2022-04-11 Jose E. Marchesi <jemarch@gnu.org>
* pickles/diff.pk: Correct handling of boundaries constraint
error.
---
ChangeLog | 5 +++++
pickles/diff.pk | 31 +++++++++++++++++++------------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index df1eebcb..3be1113a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2022-04-11 Jose E. Marchesi <jemarch@gnu.org>
+ * pickles/diff.pk: Correct handling of boundaries constraint
+ error.
+
+2022-04-11 Jose E. Marchesi <jemarch@gnu.org>
+
* libpoke/pkl-gen.pks (array_constructor): Add explicative message
to E_constraint raised from unsatisfied array boundaries.
(array_mapper): Likewise.
diff --git a/pickles/diff.pk b/pickles/diff.pk
index 9e40976c..38d1c77b 100644
--- a/pickles/diff.pk
+++ b/pickles/diff.pk
@@ -221,9 +221,16 @@ fun diff_structured = (any a, any b,
return "";
}
+ fun get_bytes = (any v) byte[]:
+ {
+ try return byte[v'size] @ v'ios : v'offset;
+ catch if E_constraint { raise E_inval; }
+ }
+
fun get_elem_bytes = (any v, uint<64> idx) byte[]:
{
- return byte[v'esize (idx)] @ v'ios : v'eoffset (idx);
+ try return byte[v'esize (idx)] @ v'ios : v'eoffset (idx);
+ catch if E_constraint { raise E_inval; }
}
fun elem_simple_p = (any elem, uint<64> idx) int:
@@ -246,13 +253,13 @@ fun diff_structured = (any a, any b,
{
if (val'elem (idx) ?! E_inval)
{
- /* Note that recursing into the element may result in E_constraint
+ /* Note that recursing into the element may result in E_inval
in case a non-byte element is found. In that case, try to
emit the thunk anyway. */
if (elem_simple_p (val, idx)
|| ! { sdiff_addrem (what, val'elem (idx),
prefix + format_ename (val'ename (idx)),
- 0); } ?! E_constraint)
+ 0); } ?! E_inval)
thunk.addrem :what what :off val'eoffset (idx) :siz val'esize (idx)
:bytes get_elem_bytes (val, idx)
:name prefix + format_ename (val'ename (idx))
@@ -286,12 +293,12 @@ fun diff_structured = (any a, any b,
/* If the element is simple, add a change to the current
thunk; otherwise recurse to handle its elements. Note that
- recursing into the element may result in E_constraint in case a
+ recursing into the element may result in E_inval in case a
non-byte element is found. In that case, try to emit the
thunk anyway. */
if (elem_simple_p (a, idx)
|| ! { sdiff_change (a'elem (idx), b'elem (idx),
- a_full_name, b_full_name); } ?!
E_constraint)
+ a_full_name, b_full_name); } ?! E_inval)
{
var a_bytes = get_elem_bytes (a, idx);
var b_bytes = get_elem_bytes (b, idx);
@@ -323,10 +330,10 @@ fun diff_structured = (any a, any b,
try
{
- if (! { sdiff_change (a, b, prefix_a, prefix_b); } ?! E_constraint)
+ if (! { sdiff_change (a, b, prefix_a, prefix_b); } ?! E_inval)
{
- var a_bytes = byte[a'size] @ a'ios : a'offset;
- var b_bytes = byte[b'size] @ b'ios : b'offset;
+ var a_bytes = get_bytes (a);
+ var b_bytes = get_bytes (b);
if (a_bytes != b_bytes)
thunk.change :aoff a'offset :asiz a'size
@@ -337,11 +344,11 @@ fun diff_structured = (any a, any b,
:bvalue format_value (b);
}
}
- catch if E_constraint
+ catch (Exception e)
{
- raise Exception { code = EC_inval,
- name = "invalid argument",
- msg = "size of compared values is not a multiple of
bytes" };
+ if (e.code == EC_inval)
+ e.msg = "size of compared values is not a multiple of bytes";
+ raise e;
}
/* There may be a thunk still to be emitted. */
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pickles: diff: correct handling of boundaries constraint error,
Jose E. Marchesi <=