leanprover-community / leanprover-community/lean

segfault on inductive type with binder starting with `_`

Open
#447 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash
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

If you create an inductive type with one constructor containing a field starting with an underscore, and then later use . notation, Lean will segfault.

Steps to Reproduce
inductive S
| mk : Π (_foo : nat → int), S

namespace S
def bar (s : S) : nat := 0

variable s : S
#check s.bar

end S

Expected behavior: s.bar : ℕ

Actual behavior: Lean segfaults

Reproduces how often: 100%

Essential features:

  • the field _foo has a name starting with an underscore
  • the inductive type has exactly one constructor
  • the type of _foo is a Pi-type

Lean thinks that S is a structure and _foo is a field containing a parent structure ("subobject") foo.

Versions

Lean (version 3.18.4, commit f539be1e867c, Release)
linux

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

Run the self-contained Lean reproducer from the issue and confirm that #check s.bar segfaults. Trace the handling of inductive types with a single constructor, underscore-prefixed fields, Pi-types, and dot notation; done means the check reports s.bar : ℕ without crashing.

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
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.