Skip to content

Commit

Permalink
test: test case for #5836
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeata committed Oct 25, 2024
1 parent f752ce2 commit 3a4198f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/lean/run/issue5836.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
inductive Foo where
| foo : (String → Option Foo) → Foo

-- Would be great if this worked, but it doesn't yet:

/--
error: failed to infer structural recursion:
Cannot use parameter #2:
failed to eliminate recursive application
map m x
-/
#guard_msgs in
def Foo.map (m : Foo → Foo) : Foo → Foo
| .foo f => .foo fun s => match f s with
| none => none
| some x => map m x
termination_by structural x => x

-- workaround:

mutual
def Foo.bar (m : Foo → Foo) : Foo → Foo
| .foo f => .foo fun s => Foo.bar_aux m (f s)
termination_by structural x => x

def Foo.bar_aux (m : Foo → Foo) : Option Foo → Option Foo
| none => none
| some x => bar m x
termination_by structural x => x
end

0 comments on commit 3a4198f

Please sign in to comment.