Skip to content

Verso docstrings on where-clause declaration cause errors #12066

@Vierkantor

Description

@Vierkantor

Prerequisites

Description

Plain text docstrings are allowed on declarations in a where clause, but Verso docstrings cause an error: "Unknown constant _ when building docstring". For example:

set_option doc.verso true

/-- This docstring works. -/
def foo := bar
  where
  /-- This docstring is not allowed:
  -- error: Unknown constant foo.bar when building docstring
   -/
  bar := 37

-- But with Verso docs disabled:
set_option doc.verso false

/-- This docstring works. -/
def foo' := bar'
  where
  /-- This docstring now also works. -/
  bar' := 37

Context

Mathlib uses docstrings, rather than plain comments, to document the declarations in a where clause.

Steps to Reproduce

  1. Enable the option doc.verso.
  2. Write a def with a where clause.
  3. Add a declaration to that where clause.
  4. Add a docstring to that declaration.

Expected behavior: The docstring does not throw any errors.

Actual behavior: There is an error "Unknown constant _ when building docstring".

Versions

Lean 4.27.0-rc1 (Mathlib, MacOS / Darwin Kernel Version 23.6.0 / arm64), Lean 4.28.0-nightly-2026-01-19 (Lean4web nightly)

Additional Information

n/a

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions