Skip to content

test: demonstrate unsimplified (when false _) in slang - #15084

Merged
Alizter merged 1 commit into
ocaml:mainfrom
chizy7:test/slang-when-false-simplification
Jun 9, 2026
Merged

Alizter merged 1 commit into
ocaml:mainfrom
chizy7:test/slang-when-false-simplification

Conversation

@chizy7

@chizy7 chizy7 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Adds repro unit tests to slang_tests.ml for the (when false _) simplification gap noted in #14457.

(when false "") is how Slang.encode serializes Nil (there is no surface syntax for Nil), so these expressions should fold away wherever a Nil does. Two cases in Slang.simplify currently miss them because the surrounding form filters Nil before its children are simplified, not after:

  • concat ["a"; (when false ""); "b"] -> Concat (Literal "a", Nil, Literal "b") (should be "ab")
  • when <unknown> (when false "") -> When (Expr …, Nil) (should be Nil)

The tests capture the current (suboptimal) output so a follow-up fix PR can flip them to the simplified result.

@chizy7

chizy7 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Tracking fix in #15090

@Alizter
Alizter merged commit 4f111a4 into ocaml:main Jun 9, 2026
29 checks passed
@Alizter

Alizter commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks!

Alizter added a commit that referenced this pull request Jun 10, 2026
Makes `Slang.simplify` fold away `(when false _)` (encoded `Nil`) even
when the `Nil` only appears after simplifying a child, in `concat` and
`when` forms:

* `concat ["a"; (when false ""); "b"]` -> `"ab"` (previously `Concat
(Literal "a", Nil, Literal "b")`)
* `when <unknown> (when false "")` -> `Nil` (previously `When (Expr …,
Nil)`)

Flips the repro tests aded in #15084 green

Addresses **A** of #15090. The `Run`-args drop (**B**) remains separate.

Fixes #15090
Refs #14457

---------

Signed-off-by: Chizaram Chibueze <[email protected]>
@Alizter Alizter added this to the 3.25.0 milestone Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants