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

Assertion failure in local_context_adapter.cpp #748

Open
1 task done
eric-wieser opened this issue Jul 29, 2022 · 1 comment
Open
1 task done

Assertion failure in local_context_adapter.cpp #748

eric-wieser opened this issue Jul 29, 2022 · 1 comment

Comments

@eric-wieser
Copy link
Member

eric-wieser commented Jul 29, 2022

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

expr local_context_adapter::translate_to(expr const & e) const {
lean_assert(!has_local_ref(e));
expr r = replace_locals(e, m_locals, m_local_refs);
lean_assert(!has_regular_local(r));
return r;
}

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)

expr local_context_adapter::translate_from(expr const & e) const {
lean_assert(!has_regular_local(e));
expr r = replace_locals(e, m_local_refs, m_locals);
lean_assert(!has_local_ref(r));
return r;
}

Reproduces how often: Every time

Versions

Lean (version 3.45.0, commit 3526539, Debug)

@eric-wieser
Copy link
Member Author

eric-wieser commented Jul 29, 2022

It would be a lot easier to debug this if I could get lean to pretty-print the value of e or r at this point: but the gdb pretty-printign only seems to work for me in VSCode with

`python print(list(gdb.selected_frame().block())[2].value(gdb.selected_frame()))

and I can't wokr out how to get hold of a formatter object inside translate_to in order to use the lean expr printing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant