lean4-htt/tests/lean/struct1.lean
Kyle Miller 9847923f9b
feat: record all structure parents in StructureInfo (#5853)
Followup to #5841. Makes the `structure` command populate the new
`parentInfo` field with all the structures in the `extends` clause.

This will require a stage0 update to fully take effect.

Breaking change: now it's a warning if a structure extends a parent
multiple times.

Breaking change: now `getParentStructures` is `getStructureSubobjects`.
Adds `getStructureParentInfo` for getting all the immediate parents.
Note that the set of subobjects is neither a subset nor a superset of
the immediate parents.

Closes #1881
2024-10-28 01:23:48 +00:00

56 lines
986 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

--
structure A (α : Type) :=
(x : α)
structure B (α : Type) :=
(x : α)
structure S : Nat := -- error expected Type
(x : Nat)
structure S extends Nat → Nat := -- error expected structure
(x : Nat)
set_option structureDiamondWarning true in
structure S' extends A Nat, A Bool := -- error field `x` already declared
(x : Nat)
structure S extends A Nat, B Bool := -- error field `x` from `B` has already been declared
(x : Nat)
structure S1 :=
(_x : Nat)
structure S2 :=
(x _y : Nat)
structure S :=
(x : Nat)
(x : Nat) -- error
structure S extends A Nat :=
(x : Nat) -- error
structure S' extends A Nat :=
(x := true) -- error type mismatch
structure S extends A Nat :=
(x : Bool := true) -- error omit type
structure S'' :=
(x : Nat := true) -- error type mismatch
private structure S :=
private mk :: (x : Nat)
private structure S :=
protected mk :: (x : Nat)
private structure S :=
protected (x : Nat)
private structure S :=
mk2 :: (x : Nat)
#check S
#check S.mk2