fix: fixes #1599 by adding correct indentation
This commit is contained in:
parent
f2abe87ddf
commit
bbc70c4cf0
2 changed files with 4 additions and 6 deletions
|
|
@ -26,21 +26,19 @@ def mkBodyForStruct (header : Header) (indVal : InductiveVal) : TermElabM Term :
|
|||
let target := mkIdent header.targetNames[0]!
|
||||
forallTelescopeReducing ctorVal.type fun xs _ => do
|
||||
let mut fields ← `(Format.nil)
|
||||
let mut first := true
|
||||
if xs.size != numParams + fieldNames.size then
|
||||
throwError "'deriving Repr' failed, unexpected number of fields in structure"
|
||||
for i in [:fieldNames.size] do
|
||||
let fieldName := fieldNames[i]!
|
||||
let fieldNameLit := Syntax.mkStrLit (toString fieldName)
|
||||
let x := xs[numParams + i]!
|
||||
if first then
|
||||
first := false
|
||||
else
|
||||
if i > numParams then
|
||||
fields ← `($fields ++ "," ++ Format.line)
|
||||
if (← isType x <||> isProof x) then
|
||||
fields ← `($fields ++ $fieldNameLit ++ " := " ++ "_")
|
||||
else
|
||||
fields ← `($fields ++ $fieldNameLit ++ " := " ++ repr ($target.$(mkIdent fieldName):ident))
|
||||
let indent := Syntax.mkNumLit <| toString ((toString fieldName |>.length) + " := ".length)
|
||||
fields ← `($fields ++ $fieldNameLit ++ " := " ++ (Format.group (Format.nest $indent (repr ($target.$(mkIdent fieldName):ident)))))
|
||||
`(Format.bracket "{ " $fields:term " }")
|
||||
|
||||
def mkBodyForInduct (header : Header) (indVal : InductiveVal) (auxFunName : Name) : TermElabM Term := do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{ name := "Joe",
|
||||
val := [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14,
|
||||
13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
|
||||
13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
|
||||
lower := 40,
|
||||
inv := _,
|
||||
flag := true }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue