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

Inlining leads to "failed to compile definition" #5808

Open
3 tasks done
MiddleAdjunction opened this issue Oct 22, 2024 · 0 comments
Open
3 tasks done

Inlining leads to "failed to compile definition" #5808

MiddleAdjunction opened this issue Oct 22, 2024 · 0 comments
Labels
bug Something isn't working depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it P-low We are not planning to work on this issue

Comments

@MiddleAdjunction
Copy link

MiddleAdjunction commented Oct 22, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

Consider the following simple definition of data C : Type and binary relation Eqv : C → C → Type over it.

inductive C : Type
| C0 : C
| C1 : C → C
open C

-- @[inline] -- <-- [HERE]
def id_C (c : C) : C :=
  match c with
  | C0    => C0
  | C1 c' => C1 (id_C c')

inductive Eqv : C → C → Type where
| Refl : Eqv c        c
| IdC  : Eqv (id_C c) c
open Eqv

def id_Eqv  (eq : Eqv c₁ c₂) : Eqv c₁ c₂ :=
  match eq with
  | Refl => Refl
  | IdC  => IdC

Notice that the relation introduces an equality on indices that involves a simple recursive function id_C.

Adding the @[inline] annotation for id_C results in the following error message:

failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Original.id_Eqv.match_1', and it does not have executable code

This is not necessarily a bug in Lean's internals if inline is not meant to be used on recursive functions. In that case, there should arguably be a clear message warning about the misuse of inline, as the current error can be quite misleading.

Context

I raised this issue on a Discord server (Lean 4 anarchy); the description above summarises the issue fairly well.

Steps to Reproduce

Run the code above with @[inline] annotation on id_C (i.e., uncomment the part labelled [HERE]).

Expected behavior: There should arguably be at least a clear message warning about the misuse of inline on id_C.

Actual behavior: User gets the following cryptic error message pointing to id_Eqv:

failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Original.id_Eqv.match_1', and it does not have executable code

Versions

[4.12.0-nightly-2024-10-22]

Impact

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

@MiddleAdjunction MiddleAdjunction added the bug Something isn't working label Oct 22, 2024
@Kha Kha added the depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it label Oct 25, 2024
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working depends on new code generator We are currently working on a new compiler (code generator) for Lean. This issue/PR is blocked by it P-low We are not planning to work on this issue
Projects
None yet
Development

No branches or pull requests

3 participants