From 04ff1f85536b8f62c6f71dc160247d0a58e17f69 Mon Sep 17 00:00:00 2001 From: x_ror <16686943+x-ror@users.noreply.github.com> Date: Wed, 18 Nov 2026 23:08:14 +0200 Subject: [PATCH 1/2] fix(ci): bun-format scripts/fmt-if.mjs; drop the shim's comments - scripts/fmt-if.mjs was never run through `bun fmt`, so `make check-js` failed on master after the Lava sync (#73). Formatted; same fix as in Lava. - pkg/html/shim/larva_html.c: the owner removed the explanatory comments. Co-Authored-By: Claude Opus 5.5 --- pkg/html/shim/larva_html.c | 39 ++------------------------------------ scripts/fmt-if.mjs | 9 ++++++--- 2 files changed, 8 insertions(+), 40 deletions(-) diff --git a/pkg/html/shim/larva_html.c b/pkg/html/shim/larva_html.c index 6d0df2d..b126b6f 100644 --- a/pkg/html/shim/larva_html.c +++ b/pkg/html/shim/larva_html.c @@ -1,37 +1,22 @@ -// The C side of pkg/html: the few lexbor calls that are inline functions, macros or -// struct reads, which Odin cannot bind directly, plus the one hook the incremental -// parser needs (see larva_html_begin). Everything else is bound from Odin -// (pkg/html/lexbor.odin). Built by scripts/build-lexbor.sh. - #include #include #include #include #include -// One per document being parsed. The tree builder installs its own token callback on -// the tokenizer when chunk parsing begins; we wrap it so we see every token first. typedef struct { lxb_html_tokenizer_token_f orig; void *orig_ctx; lxb_html_tree_t *tree; - lxb_dom_node_t *script; // the ` that is not -// closing a script element (inside a comment, in plain text) never reaches here as an -// end tag with that current node, so it is ignored. static lxb_html_token_t *larva_hook_cb(lxb_html_tokenizer_t *tkz, lxb_html_token_t *token, void *ctx) { larva_html_hook *h = ctx; @@ -59,8 +39,6 @@ static lxb_html_token_t *larva_hook_cb(lxb_html_tokenizer_t *tkz, lxb_html_token return h->orig(tkz, token, h->orig_ctx); } -// Starts chunked parsing of `doc` and installs the hook. NULL on failure; free with -// larva_html_hook_free after the document's parse has ended. larva_html_hook *larva_html_begin(lxb_html_document_t *doc) { if (lxb_html_document_parse_chunk_begin(doc) != LXB_STATUS_OK) { return NULL; @@ -85,9 +63,6 @@ larva_html_hook *larva_html_begin(lxb_html_document_t *doc) { return h; } -// Returns the script element closed since the last call, and clears it. *closed is -// how many script end tags were seen in that time: the parser cuts its slices so that -// it is never more than 1, and treats more as a failure rather than lose a script. lxb_dom_node_t *larva_html_take_script(larva_html_hook *h, size_t *closed) { lxb_dom_node_t *s = h->script; *closed = h->closed; @@ -104,8 +79,6 @@ lxb_dom_node_t *larva_html_document_node(lxb_html_document_t *doc) { return lxb_dom_interface_node(doc); } -// textContent of `node`. The bytes belong to the document; release them with -// larva_html_text_free. lxb_char_t *larva_html_text(lxb_dom_node_t *node, size_t *len) { return lxb_dom_node_text_content(node, len); } @@ -116,8 +89,6 @@ void larva_html_text_free(lxb_dom_node_t *node, lxb_char_t *text) { } } -// The value of attribute `name` on element `node`, or NULL when absent. Owned by the -// element; valid until the element changes. const lxb_char_t *larva_html_attr(lxb_dom_node_t *node, const lxb_char_t *name, size_t name_len, size_t *len) { return lxb_dom_element_get_attribute(lxb_dom_interface_element(node), name, name_len, len); } @@ -146,8 +117,6 @@ larva_css *larva_css_create(void) { return NULL; } - // querySelectorAll reports a node once, however many selectors of a list - // (`a, a.x`) it matches; lexbor's default reports it once per selector. lxb_selectors_opt_set(e->selectors, LXB_SELECTORS_OPT_MATCH_FIRST); return e; } @@ -162,7 +131,6 @@ void larva_css_destroy(larva_css *e) { free(e); } -// NULL when `css` is not a valid selector list. lxb_css_selector_list_t *larva_css_compile(larva_css *e, const lxb_char_t *css, size_t len) { lxb_css_selector_list_t *list = lxb_css_selectors_parse(e->parser, css, len); @@ -183,8 +151,6 @@ static lxb_status_t larva_css_found(lxb_dom_node_t *node, lxb_css_selector_speci return f->found(node, f->ctx) ? LXB_STATUS_STOP : LXB_STATUS_OK; } -// Matches the descendants of `root` (not `root` itself), in tree order. A stop from -// `found` is success, not an error. bool larva_css_find(larva_css *e, lxb_dom_node_t *root, const lxb_css_selector_list_t *list, larva_css_found_f found, void *ctx) { larva_css_find_ctx f = {found, ctx}; @@ -192,7 +158,6 @@ bool larva_css_find(larva_css *e, lxb_dom_node_t *root, const lxb_css_selector_l return st == LXB_STATUS_OK || st == LXB_STATUS_STOP || st == LXB_STATUS_STOPPED; } -// outerHTML of `node`. lxb_status_t larva_html_serialize_node(lxb_dom_node_t *node, lxb_html_serialize_cb_f cb, void *ctx) { return lxb_html_serialize_tree_cb(node, cb, ctx); } diff --git a/scripts/fmt-if.mjs b/scripts/fmt-if.mjs index 2e4f94d..c0f7e7f 100644 --- a/scripts/fmt-if.mjs +++ b/scripts/fmt-if.mjs @@ -121,7 +121,8 @@ function formatSource(src, isC) { const { code, state: next } = scan(line, state, isC); state = next; const indent = line.match(/^\s*/)[0]; - const spread = !isC && !startState.raw && !startState.block ? spreadOneLineBlock(line, code, indent) : null; + const spread = + !isC && !startState.raw && !startState.block ? spreadOneLineBlock(line, code, indent) : null; out.push(...(spread ?? [line])); } @@ -162,11 +163,13 @@ function formatSource(src, isC) { if (!seenOpen && !isC && / do /.test(src2[j])) break; // a `do` form odinfmt left if (j - i > 2000) break; } - if (end + 1 < src2.length && !isBlank(src2[end + 1]) && !closesOrLabels(src2[end + 1])) blankAfter.add(end); + if (end + 1 < src2.length && !isBlank(src2[end + 1]) && !closesOrLabels(src2[end + 1])) + blankAfter.add(end); } for (let i = 0; i < src2.length; i++) { - if (blankBefore.has(i) && !(result.length && isBlank(result[result.length - 1]))) result.push(''); + if (blankBefore.has(i) && !(result.length && isBlank(result[result.length - 1]))) + result.push(''); result.push(src2[i]); if (blankAfter.has(i)) result.push(''); } From e65871805ad1657f9cb8a7c008febf71c18ab033 Mon Sep 17 00:00:00 2001 From: x_ror <16686943+x-ror@users.noreply.github.com> Date: Wed, 18 Nov 2026 23:10:26 +0200 Subject: [PATCH 2/2] fix(ci): let the STATIC_EAGER cross-check read odinfmt's `[?]string {` odinfmt puts a space before the brace of the list in lazy_builtins_test.odin, and the script test's pattern required none, so make check-js failed on it once the first fix let the format check through. Co-Authored-By: Claude Opus 5.5 --- scripts/check-js-graph.test.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/check-js-graph.test.mjs b/scripts/check-js-graph.test.mjs index f5a4902..2084154 100644 --- a/scripts/check-js-graph.test.mjs +++ b/scripts/check-js-graph.test.mjs @@ -333,7 +333,8 @@ test('eager: a function-body require does not make its target eager', () => { // that list equal to what the ratchet computes, so neither can drift alone. test('eager: the Odin cross-check list matches the computed set', () => { const odin = readFileSync(join(ROOT, 'cmd', 'lava', 'lazy_builtins_test.odin'), 'utf8'); - const m = /STATIC_EAGER :: \[\?\]string\{([^}]*)\}/.exec(odin); + // odinfmt writes `[?]string {`; older text had no space before the brace. + const m = /STATIC_EAGER :: \[\?\]string\s*\{([^}]*)\}/.exec(odin); assert.ok(m, 'STATIC_EAGER not found in lazy_builtins_test.odin'); const listed = [...m[1].matchAll(/"([^"]+)"/g)].map((x) => x[1]).sort(); assert.deepEqual(listed, eagerModules(ROOT));