From 8d08e82b7c7da6384b16950558e2ef426787cfed Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 26 Sep 2026 12:17:47 +0700 Subject: [PATCH] The paren printer breaks an if-let as it breaks an if, and a one-key dyn get takes no slot. --- lib/check.ml | 7 ++++++- lib/paren_printer.ml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/check.ml b/lib/check.ml index acbe507d..ccb4e395 100644 --- a/lib/check.ml +++ b/lib/check.ml @@ -11016,9 +11016,14 @@ and checked_get ctx ~want loc (target : Tast.expr) (idx : Ast.expr list) = and dyn_get ctx ~want loc (target : Tast.expr) (keys : Ast.expr list) = let nil () = rt loc Types.Dyn "flan_dyn_nil" [] in let one v k = rt loc Types.Dyn "flan_dyn_get_at" [ v; k; here loc ] in + (* A slot per key only when there are several: one key is passed as it + stands, so a single-key get compiles as it always did. *) + let slotted = List.length keys > 1 in let keys = map_lr - (fun k -> (fresh_slot ctx Types.Dyn, check ctx ~want:Types.Dyn k)) + (fun k -> + let v = check ctx ~want:Types.Dyn k in + ((if slotted then fresh_slot ctx Types.Dyn else -1), v)) keys in let kvar (s, _) = mk loc Types.Dyn (Tast.Local s) in diff --git a/lib/paren_printer.ml b/lib/paren_printer.ml index fd32ae83..4bd57378 100644 --- a/lib/paren_printer.ml +++ b/lib/paren_printer.ml @@ -38,7 +38,7 @@ let rec flat spell (f : Form.t) = (* Heads whose arguments are statements or clauses rather than values: these break one argument to a line, never filled. *) let statement_heads = - [ "let"; "loop"; "set"; "if"; "when"; "unless"; "cond"; "while"; "until"; + [ "let"; "loop"; "set"; "if"; "if-let"; "when"; "unless"; "cond"; "while"; "until"; "dotimes"; "match"; "handler-case"; "handler-bind"; "restart-case"; "return"; "defer"; "do"; "fn"; "with-allocator"; "comment"; "quasiquote"; "break"; "continue" ]