RED: io/print_str must print exactly the bytes of its argument — refs #29
Two RED E2E tests that pin the byte-faithful-print property of io/print_str. Both fail today because the codegen at crates/ailang-codegen/src/lib.rs:2754 lowers the op to a C `@puts` call, which writes the string plus a trailing newline. - io_print_str_does_not_append_auto_newline: (seq (do io/print_str "a") (do io/print_str "b")) → stdout "ab" current: "a\nb\n" - io_print_str_does_not_double_embedded_newline: (do io/print_str "x\n") → stdout "x\n" current: "x\n\n" Assertions compare RAW stdout (no .trim()) — the byte-level property IS the assertion target. Empirically caught in the cross-model-authoring naming-A/B run on 2026-05-21 (experiments/2026-05-21-naming-ab/runs/r1/): Qwen3- Coder repeatedly wrote `(do io/print_str "text\n")` with explicit \n, expecting byte-faithful output, and got doubled newlines — failing every t3_main_prints stdout match across all three cohorts. GREEN side (codegen swap @puts → fputs(s, @stdout) + sweep of existing fixtures that implicitly relied on the auto-newline) is the next commit, via implement mini-mode. refs #29
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
(module print_str_embedded_newline_no_doubling
|
||||
(fn main
|
||||
(doc "RED fixture for Gitea #29 (companion to print_str_no_auto_newline.ail): when the author embeds a single `\\n` in the argument, exactly one newline must reach stdout — not two. Today the codegen lowers io/print_str to `@puts(ptr)` which appends its own newline, so this program emits \"x\\n\\n\" (two newlines) instead of the author-intended \"x\\n\". Pins the no-doubling property as a separate axis from the no-auto-newline property: even authors who want a newline must not get a doubled one.")
|
||||
(type (fn-type (params) (ret (con Unit)) (effects IO)))
|
||||
(params)
|
||||
(body (do io/print_str "x\n"))))
|
||||
@@ -0,0 +1,6 @@
|
||||
(module print_str_no_auto_newline
|
||||
(fn main
|
||||
(doc "RED fixture for Gitea #29: `io/print_str` must print exactly the bytes of its argument with NO auto-newline. Today the codegen lowers this op to a C `@puts(ptr)` call, which writes the string PLUS a trailing newline — so two consecutive prints of single-character strings emit \"a\\nb\\n\" instead of the expected \"ab\". This is the de-facto-println behaviour LLM authors (Qwen3-Coder, naming-A/B run 2026-05-21) trip over when they write explicit `\\n` and get doubled newlines. Property protected once the codegen swaps `@puts` for `fputs(s, stdout)`: io/print_str is a byte-faithful print, the author chooses whether to embed a newline.")
|
||||
(type (fn-type (params) (ret (con Unit)) (effects IO)))
|
||||
(params)
|
||||
(body (seq (do io/print_str "a") (do io/print_str "b")))))
|
||||
Reference in New Issue
Block a user