Skip to content

Commit 0acdf54

Browse files
authored
feat(slang): when with Nil body is Nil (#13773)
2 parents 02467ef + addc550 commit 0acdf54

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/dune_lang/slang.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ let rec simplify = function
305305
let combined_sw = String_with_vars.make ~quoted loc parts in
306306
Literal combined_sw)
307307
else Form (loc, Concat (List.map xs ~f:simplify))
308+
| When (_, Nil) -> Nil
308309
| When (condition, t) ->
309310
let simplified_condition = simplify_blang condition in
310311
(match (simplified_condition : blang) with

test/expect-tests/dune_lang/slang_tests.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,9 @@ let%expect_test "when unknown" =
326326
[%expect {| When (Expr (Literal (template "%{pkg-self:x}")), Literal "hello") |}]
327327
;;
328328

329-
(* CR-soon Alizter: when with nil body should reduce to Nil *)
330329
let%expect_test "when unknown nil" =
331330
print_slang (Slang.when_ (expr (pform "x")) Slang.Nil);
332-
[%expect {| When (Expr (Literal (template "%{pkg-self:x}")), Nil) |}]
331+
[%expect {| Nil |}]
333332
;;
334333

335334
(* Slang: If *)

0 commit comments

Comments
 (0)