leanprover / leanprover/lean4

simp attribute + unknown identifiers = internal exception #3 / PANIC at Lean.MetavarContext.getDecl Lean.MetavarContext:448:17: unknown metavariable

Open
#12,020 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

Prerequisites
Description

The code below produces a PANIC at the first @[simp] and an internal exception #3 at the second one.

Context
set_option autoImplicit false

structure Foo where
  foo := 37

variable {G : Foo}
def Foo.bar {U : Type} (f : Nat → Nat) := G.foo = G.foo

variable (C : G.bar baz)
include C

@[simp]
theorem quux : G.foo ↔ G.foo :=
  sorry

@[simp]
theorem eggs : true :=
  sorry
Steps to Reproduce
  1. Move the cursor to either simp

Expected behavior:: Probably some unknown identifier error depending on where the "real" error is occuring, but alternatively some error about metavariables without a backtrace if that's appropriate.

Actual behavior: : Observe a backtrace at the first one, and an internal exception at the second

Versions

[Output of #version or #eval Lean.versionString] 4.27.0-rc1
[OS version, if not using live.lean-lang.org.] macOS

Additional Information
Impact

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the self-contained reproducer with Lean 4.27.0-rc1 and moving the cursor to each simp attribute. Inspect the reported panic at Lean.MetavarContext.getDecl and the internal exception from the second simp. Done means the snippet reports an appropriate unknown-identifier or metavariable error without a backtrace or internal exception.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.