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.
This commit is contained in:
Chris Tate
2026-10-20 18:10:27 -05:00
parent 445b5a2ced
commit da0b70bc8d
2 changed files with 4 additions and 3 deletions
+3 -2
View File
@@ -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;
+1 -1
View File
@@ -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");
});