From 87709618f9fdf501402bc84f4e1884b7d7331621 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 26 Sep 2026 17:15:24 +0700 Subject: [PATCH] An as chain's refusals quote the whole condition, and narrowing after an as is tested. --- lib/indent_reader.ml | 4 ++-- test/programs/as-chain.fln | 2 ++ test/test_acceptance.ml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/indent_reader.ml b/lib/indent_reader.ml index 448d3ba8..286b95db 100644 --- a/lib/indent_reader.ml +++ b/lib/indent_reader.ml @@ -1473,7 +1473,7 @@ and as_chain p (x : Form.t) lvl = sym gt.loc g | tk -> failk "as-name" (where_ p) "as takes the name to bind, and found %s" (show tk) in - let bound = Form.make (Form.List [ sym at.loc "as"; g; e ]) last.loc in + let bound = mk p last.loc (Form.List [ sym at.loc "as"; g; e ]) in let rest = match (peek p).tok with | NAME "and" -> @@ -1489,7 +1489,7 @@ and as_chain p (x : Form.t) lvl = in match before @ (bound :: rest) with | [ one ] -> one - | xs -> Form.make (Form.List (sym x.loc "and" :: xs)) x.loc + | xs -> mk p x.loc (Form.List (sym x.loc "and" :: xs)) (* The if an [if let] head was read into, rewritten to (if-let [P v] then else): [(if [P v] a b)], [(when [P v] body ...)] and an elif chain's diff --git a/test/programs/as-chain.fln b/test/programs/as-chain.fln index eda9bc5b..4bdd4055 100644 --- a/test/programs/as-chain.fln +++ b/test/programs/as-chain.fln @@ -81,6 +81,8 @@ fn main() let n: i32? = Some(40) if n? and half(n) as h and n + h > 50 println(n + h) + if half(6) as h and n? and n + h > 40 + println(n + h) ;; while: pop while the next cell is empty. let i = 1 let seen = 0 diff --git a/test/test_acceptance.ml b/test/test_acceptance.ml index 1484a776..7fc52f1f 100644 --- a/test/test_acceptance.ml +++ b/test/test_acceptance.ml @@ -2279,7 +2279,7 @@ let () = (* e as g inside an and chain, typed and dyn (decision 136). *) ("as-chain.fln", "empty -1\nelse sees the outer g 100\nafter 100\n-3\nfalse\n3 5\nnot less\n40 -1\n\ - empty big other half other\n1 2 3 ran 1\n4\n1 3 stopped\n3\n60\n-4 5\n"); + empty big other half other\n1 2 3 ran 1\n4\n1 3 stopped\n3\n60\n43\n-4 5\n"); ("as-chain-dyn.fln", "dog nobody ann\n4 nil nil\n6 2\n5\n-1\n") ]; (* x! over nothing traps at its site and names the expression. *) List.iter