This commit is contained in:
Leonardo de Moura 2022-11-18 08:47:53 -08:00
parent f74fee07e6
commit a7107aedb3
3 changed files with 13 additions and 2 deletions

View file

@ -190,7 +190,7 @@ def elabClassInductive (modifiers : Modifiers) (stx : Syntax) : CommandElabM Uni
def getTerminationHints (stx : Syntax) : TerminationHints :=
let decl := stx[1]
let k := decl.getKind
if k == ``Parser.Command.def || k == ``Parser.Command.theorem || k == ``Parser.Command.instance then
if k == ``Parser.Command.def || k == ``Parser.Command.abbrev || k == ``Parser.Command.theorem || k == ``Parser.Command.instance then
let args := decl.getArgs
{ terminationBy? := args[args.size - 2]!.getOptional?, decreasingBy? := args[args.size - 1]!.getOptional? }
else

View file

@ -101,7 +101,7 @@ def declVal :=
withAntiquot (mkAntiquot "declVal" `Lean.Parser.Command.declVal (isPseudoKind := true)) <|
declValSimple <|> declValEqns <|> whereStructInst
def «abbrev» := leading_parser
"abbrev " >> declId >> ppIndent optDeclSig >> declVal
"abbrev " >> declId >> ppIndent optDeclSig >> declVal >> terminationSuffix
def optDefDeriving :=
optional (atomic ("deriving " >> notSymbol "instance") >> sepBy1 ident ", ")
def «def» := leading_parser

11
tests/lean/run/1848.lean Normal file
View file

@ -0,0 +1,11 @@
abbrev f : Nat → Nat
| 0 => 0
| n + 1 => f n
termination_by _ n => n
mutual
abbrev f1 : Nat → Nat
| 0 => 0
| n + 1 => f1 n
end
termination_by _ n => n