Skip to content

Include duplicates typeclass instances #21832

@RalfJung

Description

@RalfJung

Example due to @robbertkrebbers:

Class Foo (n : nat) := {}.

Module foo.
  Global Instance foo_S n : Foo n -> Foo (S n) := {}.

  (* fails immediately *)
  Goal Foo 100. Fail apply _. Abort.
End foo.

Module bar.
  Include foo.

  (* takes forever *)
  Goal Foo 100. Timeout 10 apply _. Abort.
End bar.

The expected behavior is that Include brings names and other things like notations into scope, but doesn't duplicate typeclass hints. But instead we get duplicate hints which leads to backtracking which makes that failing TC search take exponential time.

With its current behavior, Include is unfortunately entirely unusable for any typeclass-using development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions