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

Num lit in OfNat instance fails with poor error message #875

Closed
1 task done
ammkrn opened this issue Dec 14, 2021 · 1 comment
Closed
1 task done

Num lit in OfNat instance fails with poor error message #875

ammkrn opened this issue Dec 14, 2021 · 1 comment

Comments

@ammkrn
Copy link
Contributor

ammkrn commented Dec 14, 2021

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 fails; even with pp.all true, the error message isn't terribly helpful since it doesn't do anything with the literal 1 :

set_option pp.all true
structure Title where
  val : String

instance : OfNat Title 1 where
  ofNat := ⟨""⟩

-- failed to synthesize instance OfNat.{0} Title 1
example : Title := 1

Looking at the lean4 repo, the workaround seems to be instance : OfNat Title (nat_lit 1) := ..., which does work, but this seems like something that would frustrate new users.

Versions

Lean (version 4.0.0-nightly-2021-12-13, commit 3a6cc77, Release)
MacOS 11.4

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

2 participants