ocaml: phase 4 'let open M in body' local opens (+3 tests, 478 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 21s
Parser detects 'let open' as a separate let-form, parses M as a path (Ctor(.Ctor)*) directly via inline AST construction (no source slicing since cur-pos is only available in ocaml-parse-program), and emits (:let-open PATH BODY). Eval resolves the path to a module dict and merges its bindings into the env for body evaluation. Now: let open List in map (fun x -> x * 2) [1;2;3] = [2;4;6] let open Option in map (fun x -> x + 1) (Some 5) = Some 6
This commit is contained in:
@@ -1178,6 +1178,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 4801)
|
||||
(eval "(ocaml-run-program \"module M = struct let x = 1 and y = 2 end ;; M.x + M.y\")")
|
||||
|
||||
;; ── let open M in body ────────────────────────────────────────
|
||||
(epoch 4900)
|
||||
(eval "(ocaml-run \"let open List in length [1;2;3]\")")
|
||||
(epoch 4901)
|
||||
(eval "(ocaml-run \"let open List in map (fun x -> x * 2) [1;2;3]\")")
|
||||
(epoch 4902)
|
||||
(eval "(ocaml-run \"let open Option in map (fun x -> x + 1) (Some 5)\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1867,6 +1875,11 @@ check 4703 "((1+2) : int) * 3" '9'
|
||||
check 4800 "module rec a/b mutual" '1'
|
||||
check 4801 "module x and y" '3'
|
||||
|
||||
# ── let open M in body ─────────────────────────────────────────
|
||||
check 4900 "let open List; length" '3'
|
||||
check 4901 "let open List; map" '(2 4 6)'
|
||||
check 4902 "let open Option; map" '("Some" 6)'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user