From da0b70bc8deae47b8858d5c461b70d437dd05f58 Mon Sep 17 00:00:00 2001 From: Chris Tate Date: Tue, 20 Oct 2026 18:10:27 -0500 Subject: [PATCH] Leave an Error's code to the generic store, and allow test units to include scr_js.h The generic store keeps a native Error's code slot in step with writes through its checked view, as it does for name, message, stack and cause, so the store cache leaves `code` to it. The header invariant accepts scr_js_*.test.c units, which link the dynamic tier. --- packages/runtime/src/scr_js_object.c | 5 +++-- packages/runtime/test/headers.test.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/runtime/src/scr_js_object.c b/packages/runtime/src/scr_js_object.c index 87f3024a0..187fba736 100644 --- a/packages/runtime/src/scr_js_object.c +++ b/packages/runtime/src/scr_js_object.c @@ -252,10 +252,11 @@ ScrDyn *scr_js_load_probe(ScrDyn *receiver, const ScrStr *key, ScrJsIc *ic) { /* ── stores ───────────────────────────────────────────────────────────── */ /* The generic store keeps a native Error's fields in sync with these keys - * of its checked view; caches leave them to it. */ + * of its checked view (scr_json.c's scr_error_sync_slots); caches leave + * them to it. */ static bool scr_js_error_synced_key(const ScrStr *key) { switch (key->len) { - case 4: return memcmp(key->data, "name", 4) == 0; + case 4: return memcmp(key->data, "name", 4) == 0 || memcmp(key->data, "code", 4) == 0; case 5: return memcmp(key->data, "cause", 5) == 0 || memcmp(key->data, "stack", 5) == 0; case 7: return memcmp(key->data, "message", 7) == 0; default: return false; diff --git a/packages/runtime/test/headers.test.ts b/packages/runtime/test/headers.test.ts index fc6ea737e..42da08364 100644 --- a/packages/runtime/test/headers.test.ts +++ b/packages/runtime/test/headers.test.ts @@ -74,6 +74,6 @@ test("only dynamic-tier units include scr_js.h", () => { const includers = readdirSync(srcDir) .filter((name) => /\.(c|h)$/.test(name)) .filter((name) => /^#include "scr_js\.h"/m.test(readFileSync(join(srcDir, name), "utf8"))); - expect(includers.filter((name) => !/^scr_js_\w+\.c$/.test(name))).toEqual([]); + expect(includers.filter((name) => !/^scr_js_\w+(\.test)?\.c$/.test(name))).toEqual([]); expect(includers).toContain("scr_js_value.c"); });