fix: enforce choice invariant in ElimDeadBranches (#11398)
This PR fixes a broken invariant in the choice nodes of ElimDeadBranches. Closes: #11389 and #11393
This commit is contained in:
parent
a4f9a793d9
commit
586ea55c0d
2 changed files with 24 additions and 3 deletions
|
|
@ -84,12 +84,12 @@ choice node further down the tree.
|
|||
partial def addChoice (env : Environment) (vs : List Value) (v : Value) : List Value :=
|
||||
match vs, v with
|
||||
| [], v => [v]
|
||||
| v1@(ctor i1 _ ) :: cs, ctor i2 _ =>
|
||||
| v1@(ctor i1 vs1) :: cs, ctor i2 vs2 =>
|
||||
if i1 == i2 then
|
||||
(merge env v1 v) :: cs
|
||||
ctor i1 (Array.zipWith (merge env) vs1 vs2) :: cs
|
||||
else
|
||||
v1 :: addChoice env cs v
|
||||
| _, _ => panic! "invalid addChoice"
|
||||
| _, _ => panic! s!"invalid addChoice {repr v} into {repr vs}"
|
||||
|
||||
/--
|
||||
Merge two values into one. `bot` is the neutral element, `top` the annihilator.
|
||||
|
|
|
|||
21
tests/lean/run/11389.lean
Normal file
21
tests/lean/run/11389.lean
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/-!
|
||||
Regression tests for #11393 and #11389
|
||||
-/
|
||||
|
||||
#guard_msgs in
|
||||
open System in
|
||||
def loadModuleContent : IO Unit := do
|
||||
let lakefile : FilePath := "lakefile.lean"
|
||||
|
||||
if !(← lakefile.pathExists) then
|
||||
IO.println "nope"
|
||||
|
||||
discard <| IO.Process.output {
|
||||
cmd := "ls", args := #[]
|
||||
}
|
||||
|
||||
#guard_msgs in
|
||||
def test (s : String) : IO Bool := do
|
||||
if s.startsWith "x" then return true
|
||||
let b ← IO.Process.output {cmd := "true", args := #[]}
|
||||
return b.exitCode == 0
|
||||
Loading…
Add table
Reference in a new issue