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

noncomputable structure defaults cannot be marked noncomputable #2710

Closed
1 task done
eric-wieser opened this issue Oct 18, 2023 · 0 comments · Fixed by #5531
Closed
1 task done

noncomputable structure defaults cannot be marked noncomputable #2710

eric-wieser opened this issue Oct 18, 2023 · 0 comments · Fixed by #5531
Labels
bug Something isn't working

Comments

@eric-wieser
Copy link
Contributor

Prerequisites

  • Put an X between the brackets on this line if you have done all of the following:
    • Check that your issue is not already filed.
    • Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.

Description

The following code:

noncomputable def ohno := 1

structure OhNo where
  x := ohno

gives the error

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

As directed by the error message, after some consideration I tried to mark it noncomputable, but the following is not legal syntax:

noncomputable def ohno := 1

structure OhNo where
  x := noncomputable ohno

Neither OhNo.mk nor OhNo.x are noncomputable here; only the metadata used to populate the default arguments.

Context

Discussed on Zulip.
This example is contrived, but there are a very large number of noncomputable definitions in mathlib (many of which are only marked noncomputable because this avoids a very slow compilation pass).
Default structure initializers are rarely used in mathlib, so the impact is low

Steps to Reproduce

Run the code above

Expected behavior: Either lean emits no diagnostics, or it emits an error telling me how to fix the problem.

Actual behavior: Lean rejects the code above and leaves me with an unsolvable riddle about how to fix it.

Versions

[Output of lean --version in the folder that the issue occured in]
[OS version]

Impact

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant