Skip to content

The migrator rules M*LIB's upstream B+tree test exposed; the gate runs c-migrator-basic-tests - #2576

Merged
ehartford merged 4 commits into
mainfrom
mlib-tests
Oct 23, 2026
Merged

ehartford merged 4 commits into
mainfrom
mlib-tests

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

The migrator rules M*LIB's upstream B+tree test exposed (task: tests/test-mbptree.c under With, the Phase 4 gate), each general with a fixture, and the gate drift that let a basic-tests red land.

  • std.libc gains C's stdio input and string scanning families (fscanf, ungetc, strcoll, strspn, strcspn, strpbrk, strncat); the migrator's libc allowlist and ownership observer list admit them; libc-surface-check's standard list names them.
  • A declaration directly under a case label is the arm's local, scoped to the arm, its scope threading through the arm's later statements (m-string.h's octal escape parser). Fixture switch_arm_decl.
  • A call through a conditional callee: a literal condition ((1 ? f : g)(x), M*LIB's M_IF) folds to its arm; a runtime condition lowers as one call per arm under the condition, the arguments lowered once and shared and coerced by the then-arm's declaration. Fixture ternary_callee.
  • The gate runs c-migrator-basic-tests (CLAUDE.md named it in the fixed list; build.w did not have it, so the target ran only at release tier). The red it hid: STC corpus (std.stc) and its test lanes: stdlib_sourcing_plan Phase 3, the pipeline half #2556's rule renders a string literal in a variadic position as C's const char*, and the CI: run the full green battery (build :test) on linux presubmit #791 fixture macro_body_string_literal still expected a With str there. The rule is right (a str in a variadic C slot is read as two words; A str passed in a variadic C position is read as two words #2574 filed for the compiler), so the fixture expects the pointer.

With these, the whole-program migration of tests/test-mbptree.c (M_USE_STDIO=1, as upstream's test-obj.h needs) checks clean except for #2575: a program alias named like a lazily-skipped std alias forces the std alias to resolve in the program's context ("unknown type" inside std.engines.mlib.defs), which blocks the test lane itself and shows a stage1/stage2 divergence. The lane follows once #2575 is fixed.

Eric Hartford added 4 commits October 23, 2026 03:10
…ungetc, strcoll, strspn, strcspn, strpbrk, strncat

M*LIB's upstream B+tree test (tests/test-mbptree.c with m-string.h and
tests/test-obj.h, the Phase 4 gate) parses through `fscanf`/`ungetc` and
scans with `strpbrk`/`strspn`/`strcspn`/`strcoll`; the migrator refused
each as an "unsupported filtered system variable". All seven are C
standard: std.libc declares them, the migrator's libc allowlist and its
ownership observer list admit them (none retains a pointer it is handed),
and libc-surface-check's standard list names them.
`default: int d1 = c - '0'; int d2 = ...; return d2 + 1;` (m-string.h's
octal escape parser) bailed at the DeclStmt: a switch arm's statements
were lowered one by one with the switch's scope, and only a compound
block threaded declarations through `lower_decl_stmt_structural`. An arm's
statement now lowers through `lower_arm_stmt_ir`: a declaration is the
arm's local, scoped to the arm as a block's is to the block, and the arm's
scope threads through its later statements. Fixture: switch_arm_decl.
…ts the C pointer a variadic literal is

CLAUDE.md names c-migrator-basic-tests in the gate's fixed list; build.w's
list did not have it, so the target ran only under the release tier's
c-migrator-tests and a red landed on main unseen: #2556's rule renders a
string literal in a variadic position as C's `const char*` (`c"…".ptr`),
and the #791 fixture still expected a With `str` there. The rule is right:
a `str` in a variadic C slot is read as two words (`fprintf(..., "%s|%d",
"compress", 7)` prints `compress|8`, the str's length; filed as #2574 for
the compiler). The fixture expects the pointer, and the gate runs the
target.
M*LIB's M_IF selects a function by a literal condition
(`(1 ? m_string_cat_printf : m_string_printf)(s, "%s", x)`); lowered as a
conditional over two function values it was refused, since a `...`
function is called directly, never used as a value. A conditional callee
whose condition is an integer literal, or that literal compared with
zero, folds to its arm before the call is built. Fixture: ternary_callee.

A runtime condition (`(append ? m_string_cat_cstr : m_string_set_cstr)(s,
"[")`) lowers as one call per arm under the condition, the arguments
lowered once and shared (one arm runs, as in C); the then-arm's
declaration coerces them, since C requires the arms' types to agree.
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery GREEN on 202cbc7 (seed nightly-20261020-local-3, 389 s wall; logs out/battery/ in the worktree). Gate green, c-migrator-basic-tests included.

@ehartford
ehartford marked this pull request as ready for review October 23, 2026 07:22
@ehartford
ehartford merged commit 6abd887 into main Oct 23, 2026
@ehartford
ehartford deleted the mlib-tests branch October 23, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant