ocaml: phase 5 parse ctor arg types in user type-defs (+3 tests, 409 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 36s
ocaml-hm-parse-type-src recognises primitive type names (int/bool/ string/float/unit), tyvars 'a, and simple parametric T list / T option. Replaces the previous int-by-default placeholder in ocaml-hm-register-type-def!. So 'type tag = TStr of string | TInt of int' correctly registers TStr : string -> tag and TInt : int -> tag. Pattern-match on tag gives proper field types in the body. Multi-arg / function types still fall back to a fresh tv.
This commit is contained in:
@@ -1004,6 +1004,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3005)
|
||||
(eval "(ocaml-run \"String.index_of \\\"hello\\\" \\\"ll\\\"\")")
|
||||
|
||||
;; ── HM with parsed ctor arg types ──────────────────────────────
|
||||
(epoch 3100)
|
||||
(eval "(ocaml-type-of-program \"type shape = Circle of int | Square of int;; let area s = match s with | Circle r -> r * r | Square s -> s * s;; area\")")
|
||||
(epoch 3101)
|
||||
(eval "(ocaml-type-of-program \"type tag = TStr of string | TInt of int;; TStr \\\"hi\\\"\")")
|
||||
(epoch 3102)
|
||||
(eval "(ocaml-type-of-program \"type t = A of bool | B of float;; A true\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1588,6 +1596,11 @@ check 3003 "String.split_on_char" '("a" "b" "c")'
|
||||
check 3004 "String.replace_all" '"herro"'
|
||||
check 3005 "String.index_of" '2'
|
||||
|
||||
# ── HM with parsed ctor arg types ──────────────────────────────
|
||||
check 3100 "shape -> Int" '"shape -> Int"'
|
||||
check 3101 "TStr 'hi' : tag" '"tag"'
|
||||
check 3102 "A true : t" '"t"'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user