Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(kernel) declaration has free variables error when extending class with typeclass parameter and extends #2611

Closed
1 task done
SabrinaJewson opened this issue Oct 1, 2023 · 2 comments · Fixed by #6175
Closed
1 task done
Labels
bug Something isn't working P-low We are not planning to work on this issue

Comments

@SabrinaJewson
Copy link

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Check that your issue is not already filed.
    • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.

Description

The following Lean 4 code produces an error:

class A
class B
class C [A] extends B
class D extends A, B, C
--                    ^ (kernel) declaration has free variables 'D.toC'

Context

This came about when I was defining my own classes for abstract algebra, which heavily build on other classes and use extends to minimize field repetition caused by inheritance diamonds.

Steps to Reproduce

  1. Write the code above into a Lean file
  2. Attempt to compile it

Expected behavior: No error.

Actual behavior: The type checker gives the described error.

Versions

Lean (version 4.3.0-nightly-2023-10-01, commit e6292bc, Release) on Linux 6.3.13

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@SabrinaJewson SabrinaJewson added the bug Something isn't working label Oct 1, 2023
@digama0
Copy link
Collaborator

digama0 commented Oct 1, 2023

Note that this has never worked (extends classes cannot be dependent on each other)

@SabrinaJewson
Copy link
Author

That’s surprising to me, because the following does work:

class A
class B [A]
class C extends A, B

@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Nov 22, 2024
kmill added a commit to kmill/lean4 that referenced this issue Nov 22, 2024
…ances

This PR fixes a bug with the `structure` command where if there were parents that are not represented as subobjects but which used other parents as instances, then there would be a kernel error. Closes leanprover#2611.
kmill added a commit to kmill/lean4 that referenced this issue Nov 24, 2024
…ances

This PR fixes a bug with the `structure` command where if there were parents that are not represented as subobjects but which used other parents as instances, then there would be a kernel error. Closes leanprover#2611.
github-merge-queue bot pushed a commit that referenced this issue Nov 24, 2024
…ances (#6175)

This PR fixes a bug with the `structure`/`class` command where if there
are parents that are not represented as subobjects but which used other
parents as instances, then there would be a kernel error. Closes #2611.

Note: there is still the limitation that parents that are not
represented as subobjects do not themselves provide instances to other
parents.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P-low We are not planning to work on this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants