lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

Elaboration failure with let mut whose RHS is a do notation

Open bollu opened this issue 1 year ago • 1 comments

Consider the MWE:

def fails : MetaM Unit := do
  let mut val : Bool ← do
      pure true
  -- unknown identifier val
  val := Bool.not val -- FAILS! expected to succeed.
  return ()

This can be worked around by shadowing:

def succeeds : MetaM Unit := do
  let val : Bool ← do
      pure true
  let mut val := val
  val := Bool.not val
  return ()

Reported on zulip at https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/Elaboration.20failure.20with.20let.20mut.20whose.20RHS.20is.20a.20do.20notation/near/474621276

bollu avatar Oct 03 '24 15:10 bollu