leanprover / lean4

Lean 4 programming language and theorem prover
https://lean-lang.org
Apache License 2.0
3.82k stars 325 forks source link

`And.left` and `And.right` have malformed constant info #4064

Closed fgdorais closed 1 week ago

fgdorais commented 2 weeks ago

Prerequisites

Description

In v4.8.0-rc1, the ConstantInfo for And.left and And.right are malformed and cause lean to segfault (at least on aarch64-apple-darwin). Only the field TheoremVal.all seems affected so this is perhaps related to #4035. Also note that And.left and And.right are structure fields rather than standalone theorems.

Context

Observed after updating code to v4.8.0-rc1 when an alias foo := And.left declaration caused a server crash. Zulip mention

Steps to Reproduce

This file causes lean to segfault.

import Lean

def test : Lean.CoreM (List Lean.Name) := do
  let .thmInfo tval ← Lean.getConstInfo `And.left | unreachable!
  return tval.all

#eval test

Version: Lean (version 4.8.0-rc1, aarch64-apple-darwin, commit dcccfb73cb24, Release)

Impact

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

fgdorais commented 2 weeks ago

This is perhaps limited to declarations in Init.Prelude. The following does not cause a segfault:

import Lean

structure Both (p q : Prop) : Prop where
  fst : p
  snd : q

def test : Lean.CoreM (List Lean.Name) := do
  let .thmInfo tval ← Lean.getConstInfo `Both.fst | unreachable!
  return tval.all

#eval test