leanprover-community / leanprover-community/lean

Assertion failure in local_context_adapter.cpp

Open
#748 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
434
Forks
79
PR merge metrics
No merged PRs in 30d

Description

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

The following code (from this Zulip thread) produces an assertion failure:

set_option old_structure_cmd true

class has_nat_cast (R : Type) :=
(nat_cast : ℕ → R)

class add_monoid_with_one (R : Type) extends has_nat_cast R :=
(nat_cast := sorry)
(nat_cast_zero : R := nat_cast 0)
Steps to Reproduce
  1. Obtain a debug build of lean
  2. Run lean test.lean on the file above

Expected behavior: No assertion error

Actual behavior: Two assertion errors:

LEAN ASSERTION VIOLATION
File: /workspace/lean/src/frontends/lean/local_context_adapter.cpp
Line: 59
Task: /workspace/lean/test.lean: parsing at line 6
!has_regular_local(r)
(C)ontinue, (A)bort/exit, (S)top/trap
c

https://github.com/leanprover-community/lean/blob/3526539070ea6268df5dd373deeb3ac8b9621952/src/frontends/lean/local_context_adapter.cpp#L56-L61

LEAN ASSERTION VIOLATION
File: /workspace/lean/src/frontends/lean/local_context_adapter.cpp
Line: 64
Task: /workspace/lean/test.lean: parsing at line 6
!has_regular_local(e)
(C)ontinue, (A)bort/exit, (S)top/trap
S
Aborted (core dumped)

https://github.com/leanprover-community/lean/blob/3526539070ea6268df5dd373deeb3ac8b9621952/src/frontends/lean/local_context_adapter.cpp#L63-L68

Reproduces how often: Every time

Versions

Lean (version 3.45.0, commit 3526539070ea6268df5dd373deeb3ac8b9621952, Debug)

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 with src/frontends/lean/local_context_adapter.cpp at the assertions on lines 56-61 and 63-68, then reproduce the failure using the Lean snippet in the issue with a debug build. Trace why the structure declarations create locals that fail the regular-local checks. Done means the reproducer completes without assertion errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.