Skip to content

Kernel failed to type-check due to name collision involving include #751

@Vierkantor

Description

@Vierkantor

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

Under the following conditions, we get an error in the kernel:

  • two variables, one depending on another
  • the dependent one is included, transitively includeing its dependency
  • there is a local variable with the same name as the dependency
  • the included variables are not used in the declaration

Steps to Reproduce

The following code errors:

variables (a : ℕ)
variables (ha : a = a)

include ha

theorem ex (a : ℕ) : a = a := rfl

/-
error:
kernel failed to type check declaration 'ex' this is usually due to a buggy tactic or a bug in the builtin elaborator
elaborated type:
  a = a → ℕ → ∀ (a : ℕ), a = a
elaborated value:
  λ (ha : a = a) (a a : ℕ), rfl
nested exception message:
failed to add declaration to environment, it contains local constants
-/

Expected behavior: No errors in the kernel, like when there's no name clash.

Actual behavior: An error:

error:
kernel failed to type check declaration 'ex' this is usually due to a buggy tactic or a bug in the builtin elaborator
elaborated type:
  a = a → ℕ → ∀ (a : ℕ), a = a
elaborated value:
  λ (ha : a = a) (a a : ℕ), rfl
nested exception message:
failed to add declaration to environment, it contains local constants

Reproduces how often: always

Versions

Lean (version 3.45.0, commit 22b09be, Release)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions