Skip to content

Commit 67b50f6

Browse files
committed
fix(echo): patch two exhaustiveness gaps + extend TG-4 round-trip corpus
Two warnings-as-errors surfaced when compiling the echo/product additions for the first time on a real OCaml toolchain: compiler/lib/typecheck.ml — `strand_type_of_ty` had no arms for TProd/TEcho. compiler/bin/main.ml — the debug token printer had no arms for the 8 new echo keyword tokens (ECHOCLOSE LOWER RESIDUE PAIR FST SND ECHOADD ECHOEQ). Both are straightforward exhaustiveness gaps; the design is preserved. Both get StrandDefault / print_string "<NAME>" mirroring the nearest neighbouring cases. Also extend the TG-4 round-trip corpus in test_roundtrip.ml with one entry per new echo constructor (echoClose, lower, residue, pair, fst, snd, echoAdd, echoEq) so the parse/pretty/parse round-trip guarantee is explicitly exercised for every form added by this PR. Before: dune build fails; 532 tests (not reached) After: dune build succeeds; 548/548 tests pass (16 new TG-4 entries)
1 parent f3ac1da commit 67b50f6

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

compiler/bin/main.ml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,15 @@ let dump_tokens (filename : string) : unit =
167167
| STRING s -> Printf.printf "STRING(%S)" s
168168
| IDENT s -> Printf.printf "IDENT(%s)" s
169169
| GENERATOR n -> Printf.printf "GENERATOR(%d)" n
170-
| EOF -> print_string "EOF");
170+
| EOF -> print_string "EOF"
171+
| ECHOCLOSE -> print_string "ECHOCLOSE"
172+
| LOWER -> print_string "LOWER"
173+
| RESIDUE -> print_string "RESIDUE"
174+
| PAIR -> print_string "PAIR"
175+
| FST -> print_string "FST"
176+
| SND -> print_string "SND"
177+
| ECHOADD -> print_string "ECHOADD"
178+
| ECHOEQ -> print_string "ECHOEQ");
171179
print_newline ();
172180
if tok <> EOF then loop ()
173181
in

compiler/lib/typecheck.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,8 @@ and strand_type_of_ty (t : ty) : strand_type =
584584
| TBool -> StrandNamed "Bool"
585585
| TWord _ -> StrandDefault
586586
| TTangle _ -> StrandDefault
587+
| TProd _ -> StrandDefault
588+
| TEcho _ -> StrandDefault
587589

588590
(** Convert a strand_type to a boundary element for self-crossing. *)
589591
and strand_to_type (st : strand_type) : strand_type = st

compiler/test/test_roundtrip.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ let basic_corpus : (string * string) list = [
100100
("nullary def", "def x = identity");
101101
("unary def", "def f(a) = a");
102102
("binary def", "def f(a, b) = a + b");
103+
(* Echo / structured-loss forms (PR #45) *)
104+
("echoClose", "def x = echoClose(a)");
105+
("lower", "def x = lower(a)");
106+
("residue", "def x = residue(a)");
107+
("pair", "def x = pair(a, b)");
108+
("fst", "def x = fst(a)");
109+
("snd", "def x = snd(a)");
110+
("echoAdd", "def x = echoAdd(a, b)");
111+
("echoEq", "def x = echoEq(a, b)");
103112
]
104113

105114
(* --------------------------------------------------------------------- *)

0 commit comments

Comments
 (0)