lean4 icon indicating copy to clipboard operation
lean4 copied to clipboard

fix: do not modify infotrees in `withSetOptionIn`

Open thorimur opened this issue 1 month ago • 4 comments

This PR ensures that withSetOptionIn does not modify the infotrees or error on malformed option values, and thus avoids panics in linters that traverse the infotrees with visitM.

withSetOptionIn is only intended to be used in linters, and thus should provide the linter action with the infotrees produced during elaboration without modification. However, withSetOptionIn had not only been modifying the infotrees by elaborating the option, but had been producing context-free info nodes in doing so. These caused uses of visitM and related functions to panic in typical linters.

Likewise, withSetOptionIn also should not cause the linter to error if somehow it consumes a malformed option value, but instead should fail silently.

We give an optional flag (addInfo := true) to Elab.elabSetOption which controls whether info is added to the infotrees.

This was brought up on Zulip here, and discussed briefly in office hours.

thorimur avatar Nov 21 '25 21:11 thorimur

changelog-language

thorimur avatar Nov 21 '25 22:11 thorimur

awaiting-review

thorimur avatar Nov 21 '25 23:11 thorimur

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2025-11-21 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2025-11-21 23:05:12)

leanprover-bot avatar Nov 21 '25 23:11 leanprover-bot

Mathlib CI status (docs):