Compare commits

...

2 Commits

Author SHA1 Message Date
Kim Morrison
c3486f253f fix 2025-11-10 00:14:04 +01:00
Kim Morrison
5c35405052 chore: add failing test for diamond structure docstrings 2025-11-10 00:14:04 +01:00
8 changed files with 55 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ public import Lean.Meta.Structure
public import Lean.Elab.MutualInductive
import Lean.Linter.Basic
import Lean.DocString
import Lean.DocString.Extension
public section
@@ -661,8 +662,8 @@ private partial def withStructField (view : StructView) (sourceStructNames : Lis
let mut declName := view.declName ++ fieldName
if inSubobject?.isNone then
declName applyVisibility ( toModifiers fieldInfo) declName
-- No need to validate links because this docstring was already added to the environment previously
addDocStringCore' declName ( findDocString? ( getEnv) fieldInfo.projFn)
-- Create a link to the parent field's docstring
addInheritedDocString declName fieldInfo.projFn
addDeclarationRangesFromSyntax declName ( getRef)
checkNotAlreadyDeclared declName
withLocalDecl fieldName fieldInfo.binderInfo ( reduceFieldProjs fieldType) fun fieldFVar => do

View File

@@ -0,0 +1,2 @@
import StructureDocstrings.A
import StructureDocstrings.B

View File

@@ -0,0 +1,9 @@
module
public section
class Monoid (M : Type) extends Mul M where
class DivInvMonoid (G : Type) extends Mul G where
/-- The power operation: `a ^ n = a * ··· * a`; `a ^ (-n) = a⁻¹ * ··· a⁻¹` (`n` times) -/
protected zpow : Int G G

View File

@@ -0,0 +1,7 @@
module
public import StructureDocstrings.A
public section
class GroupWithZero (G : Type) extends Monoid G, DivInvMonoid G where

View File

@@ -0,0 +1,15 @@
module
import Lean.DocString
import Lean.Meta.Basic
public import StructureDocstrings.B
public section
/-- info: The power operation: `a ^ n = a * ··· * a`; `a ^ (-n) = a⁻¹ * ··· a⁻¹` (`n` times) -/
#guard_msgs in
open Lean in
run_meta do
let env getEnv
let some r Lean.findDocString? env `GroupWithZero.zpow | failure
logInfo r

View File

@@ -0,0 +1,13 @@
name = "structure_docstrings"
defaultTargets = ["StructureDocstrings", "StructureDocstringsTest"]
[[lean_lib]]
name = "StructureDocstrings"
leanOptions = { experimental.module = true }
roots = ["StructureDocstrings.A", "StructureDocstrings.B"]
[[lean_lib]]
name = "StructureDocstringsTest"
# Elab.inServer to allow docstring tests to access .server level data
leanOptions = { experimental.module = true, Elab.inServer = true }
roots = ["StructureDocstrings.C"]

View File

@@ -0,0 +1 @@
lean4-2

View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
rm -rf .lake/build
LEAN_ABORT_ON_PANIC=1 lake build