[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 0/2] Add more context to E_constraint msg
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH 0/2] Add more context to E_constraint msg |
Date: |
Thu, 28 Dec 2023 16:34:02 +0100 |
Hi Jose.
This series enrich the msg field of E_constraint to give the user
more information of the definition location and evaluation location.
Example:
```
(poke) type A = struct { int i == 1; }
(poke) var a = A{}
(poke) a.i++
unhandled constraint violation exception
failed expression
i == 1
in field A.i evaluated at <stdin>:1:1 (defined at <stdin>:1:24)
```
I think, it's much more readable than
```
unhandled constraint violation exception
failed expression
i == 1
in field A.i
```
Imagine when you're loading a pickle that's loading another one,
and somewhere there, a constraint violation is happening.
One thing that is, IMHO, even better, is to add a `detailed_info` field
to the exception, and report the whole stack of locations from the
first expr/stmt to the core expr that is the main point of failure.
Currently, I've introduced a `locationstack' to keep track of the
location info, and only reporting the location from top of that stack.
Regards,
Mohammad-Reza
Mohammad-Reza Nabipoor (2):
pkl: report location of constraint definition
pkl: report evaluation location in E_constraint exception
ChangeLog | 54 +++++++++++++
libpoke/pkl-ast.c | 6 ++
libpoke/pkl-ast.h | 7 ++
libpoke/pkl-gen.c | 77 +++++++++++++++++++
libpoke/pkl-gen.pks | 4 +
libpoke/pkl-insn.def | 5 ++
libpoke/pkl-rt.pk | 16 ++--
libpoke/pkl-tab.y | 22 +++++-
libpoke/pvm.jitter | 113 ++++++++++++++++++++++++++++
testsuite/poke.pickles/pcap-test.pk | 3 +-
10 files changed, 299 insertions(+), 8 deletions(-)
--
2.42.1
- [PATCH 0/2] Add more context to E_constraint msg,
Mohammad-Reza Nabipoor <=