From 28bb950efe1755a42bccda41595f908ecb332182 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Sat, 20 Jun 2026 02:01:42 -0400 Subject: [PATCH] Chez inc7: batched runner handles multi-line case sources MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The batched zero-Janet runner wrote one case per TSV line, so a multi-line source (e.g. a ;comment\n inside a map literal) split the line and the case was truncated -> a false "apply non-procedure" crash. Escape \n/\t/\\ when writing the cases file and unescape in the runner before eval. Zero-Janet corpus parity 2288 -> 2293 (the 5 comment-in-map cases), 0 divergences — now within 2 of the Janet-hosted oracle (2295). Floor 2293. --- host/chez/driver.janet | 22 ++++++++++++++++++++-- test/chez/run-corpus-zero-janet.janet | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/host/chez/driver.janet b/host/chez/driver.janet index 2adf56e..9a6772b 100644 --- a/host/chez/driver.janet +++ b/host/chez/driver.janet @@ -429,7 +429,20 @@ "(define (zj-clean s)\n" # strip tabs/newlines from a message so it stays one TSV line " (list->string (map (lambda (c) (if (or (char=? c #\\tab) (char=? c #\\newline)) #\\space c))\n" " (string->list s))))\n" - "(define (zj-run label src)\n" + # cases are stored one-per-line with \\n / \\t / \\\\ escaped (a source may be + # multi-line — e.g. a ;comment\\n inside a map literal); unescape before eval. + "(define (zj-unescape s)\n" + " (let ((out (open-output-string)) (n (string-length s)))\n" + " (let loop ((i 0))\n" + " (if (>= i n) (get-output-string out)\n" + " (let ((c (string-ref s i)))\n" + " (if (and (char=? c #\\\\) (< (+ i 1) n))\n" + " (let ((d (string-ref s (+ i 1))))\n" + " (write-char (cond ((char=? d #\\n) #\\newline) ((char=? d #\\t) #\\tab) (else d)) out)\n" + " (loop (+ i 2)))\n" + " (begin (write-char c out) (loop (+ i 1)))))))))\n" + "(define (zj-run label esrc)\n" + " (define src (zj-unescape esrc))\n" " (guard (e (#t (printf \"CRASH\\t~a\\t~a\\n\" label (zj-clean (zj-err->str e)))))\n" " (let ((v (jolt-compile-eval src \"user\")))\n" " (if (string=? (jolt-final-str v) \"true\")\n" @@ -455,7 +468,12 @@ [prelude-path image-path cases &opt scheme-out cases-out] (def tsv-path (or cases-out (string "/tmp/jolt-zj-cases-" (os/getpid) ".tsv"))) (def buf @"") - (each [label src] cases (buffer/push buf label "\t" src "\n")) + # escape so each case is one TSV line even if its source is multi-line; the + # runner's zj-unescape reverses it. Backslash first, then newline/tab. + (defn- tsv-esc [s] + (->> s (string/replace-all "\\" "\\\\") (string/replace-all "\n" "\\n") + (string/replace-all "\t" "\\t"))) + (each [label src] cases (buffer/push buf label "\t" (tsv-esc src) "\n")) (spit tsv-path buf) (def prog (program-corpus-zero-janet prelude-path image-path tsv-path)) (def path (or scheme-out (string "/tmp/jolt-zj-runner-" (os/getpid) ".ss"))) diff --git a/test/chez/run-corpus-zero-janet.janet b/test/chez/run-corpus-zero-janet.janet index 4ed1e02..d2fb7c4 100644 --- a/test/chez/run-corpus-zero-janet.janet +++ b/test/chez/run-corpus-zero-janet.janet @@ -163,7 +163,7 @@ # Regression floor: raise as the Chez-hosted compiler closes gaps. The gate fails # on any NEW divergence or if pass drops below the floor. Strided runs scale to 0. -(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_ZJ_FLOOR") "2288"))) +(def base-floor (scan-number (or (os/getenv "JOLT_CHEZ_ZJ_FLOOR") "2293"))) (def floor (if (os/getenv "JOLT_CORPUS_LIMIT") 0 base-floor)) (when (or (> (length diverged) 0) (< pass floor)) (printf "REGRESSION: pass %d < floor %d or %d new divergence(s)" pass floor (length diverged)))