An as chain's refusals quote the whole condition, and narrowing after an as is tested.

This commit is contained in:
Joseph Ferano 2026-09-26 17:15:24 +07:00
parent 0598949fcb
commit 87709618f9
3 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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