ocaml: phase 2 let..and.. mutual recursion (+3 tests, 251 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 51s
Parser collects multiple bindings via 'and', emitting (:def-rec-mut BINDINGS) for let-rec chains and (:def-mut BINDINGS) for non-rec. Single bindings keep the existing (:def …) / (:def-rec …) shapes. Eval (def-rec-mut): allocate placeholder cell per binding, build joint env where each name forwards through its cell, then evaluate each rhs against the joint env and fill the cells. Even/odd mutual-rec works.
This commit is contained in:
@@ -631,6 +631,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 832)
|
||||
(eval "(ocaml-run \"Result.is_error (Error \\\"oops\\\")\")")
|
||||
|
||||
;; ── let ... and ... mutual recursion ──────────────────────────
|
||||
(epoch 850)
|
||||
(eval "(ocaml-run-program \"let rec even n = if n = 0 then true else odd (n - 1) and odd n = if n = 0 then false else even (n - 1);; even 10\")")
|
||||
(epoch 851)
|
||||
(eval "(ocaml-run-program \"let rec even n = if n = 0 then true else odd (n - 1) and odd n = if n = 0 then false else even (n - 1);; odd 7\")")
|
||||
(epoch 852)
|
||||
(eval "(ocaml-run-program \"let x = 1 and y = 2;; x + y\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1003,6 +1011,11 @@ check 830 "Result.map Ok" '("Ok" 6)'
|
||||
check 831 "Result.is_ok" 'true'
|
||||
check 832 "Result.is_error" 'true'
|
||||
|
||||
# ── let ... and ... mutual recursion ─────────────────────────────
|
||||
check 850 "even 10 (mutual rec)" 'true'
|
||||
check 851 "odd 7 (mutual rec)" 'true'
|
||||
check 852 "let x = 1 and y = 2" '3'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user