aboutsummaryrefslogtreecommitdiffstats
path: root/prototypes
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-09-25 13:31:28 +0100
committereunhhu <[email protected]>2026-09-25 13:31:28 +0100
commit50a271cc241fb9fcdb196d45ba113f74cb318b47 (patch)
treecc7da2a15a39906341f5ed22eadd12b2ad629983 /prototypes
parente22b6f5c51e9133495c632a0c80674c14083c382 (diff)
downloadpure-50a271cc241fb9fcdb196d45ba113f74cb318b47.tar.gz
pure-50a271cc241fb9fcdb196d45ba113f74cb318b47.zip
Keep event faults out of view evaluation
A view that failed (for example on a missing list item) overwrote the app's fault, so a host saw a fault after a successful event. A view now reports failure only by its result.
Diffstat (limited to 'prototypes')
-rw-r--r--prototypes/connections/module.c8
-rw-r--r--prototypes/connections/test-module.c1
2 files changed, 8 insertions, 1 deletions
diff --git a/prototypes/connections/module.c b/prototypes/connections/module.c
index c07b1e8..2e5375c 100644
--- a/prototypes/connections/module.c
+++ b/prototypes/connections/module.c
@@ -1132,12 +1132,18 @@ PureResult pure_app_reply(const PureApp *app, bool (*visit)(void *, PureSpan), v
return visit_value(app, &app->arena, app->reply, visit, context);
}
+/* A view that fails reports it by its result; the fault stays the last event's. */
static PureResult evaluate(PureApp *app, uint32_t view, Slot *out) {
double values[PURE_MODULE_STATES];
memcpy(values, app->values, sizeof(values));
app->view_arena.used = 0;
Event ev = {.app = app, .arena = &app->view_arena};
- return run(app->module, values, app->module->view_code[view], &ev, out);
+ PureFault fault = app->fault;
+ uint32_t fault_pc = app->fault_pc;
+ PureResult result = run(app->module, values, app->module->view_code[view], &ev, out);
+ app->fault = fault;
+ app->fault_pc = fault_pc;
+ return result;
}
bool pure_app_view(PureApp *app, uint32_t view, double *out) {
diff --git a/prototypes/connections/test-module.c b/prototypes/connections/test-module.c
index eb61521..8867e0a 100644
--- a/prototypes/connections/test-module.c
+++ b/prototypes/connections/test-module.c
@@ -916,6 +916,7 @@ static void lists(void) {
double value;
CHECK(number_view(&app, 0) == 0 && number_view(&app, 1) == 0 && !pure_app_view(&app, 2, &value));
CHECK(pure_app_view_text(&app, 3, text_span, &(Text){{0}, 0}) == PURE_NOT_FOUND); /* no item yet */
+ CHECK(app.fault == PURE_FAULT_NONE); /* views leave faults alone */
CHECK(pure_app_text(&app, 0, (PureSpan){(const unsigned char *)"a", 1}) == PURE_OK);
CHECK(pure_app_text(&app, 0, (PureSpan){(const unsigned char *)"b", 1}) == PURE_OK);
CHECK(pure_list_count(app.lists[1]) == 2 && app.values[2] == 1 && app.values[0] == 2);