lean4-htt/tests/lean/unknownCannotBeComplex.lean
Robert J. Simmons ab606ba754
feat: hint when an autobound variable's type fails to be a function (#11518)
This PR provides an additional hint when the type of an autobound
implicit is required to have function type or equality type — this
fails, and the existing error message does not address the fact that the
source of the error is an unknown identifier that was automatically
bound.

## Example

```
import Lean
example : MetaM String := pure ""
```

Current error message:
```
Function expected at
  MetaM
but this term has type
  ?m

Note: Expected a function because this term is being applied to the argument
  String
```

Additional error message provided by this PR:
```
Hint: The identifier `MetaM` is unknown, and Lean's `autoImplicit` option 
causes an unknown identifier to be treated as an implicitly bound variable 
with an unknown type. However, the unknown type cannot be a function, and a 
function is what Lean expects here. This is often the result of a typo or a 
missing `import` or `open` statement.
```
2025-12-05 03:07:16 +00:00

19 lines
739 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean
example : Option String := sorry
example : Maybe String := sorry
example : Result String Nat := sorry
example : Nonsense String Nat := sorry
example : MetaM String := sorry
set_option relaxedAutoImplicit false in
example : MetaM String := sorry
set_option relaxedAutoImplicit false in
example : Nonsense String := sorry
example (h₁ : α = β) (as : List α) (P : List β → Type) : P (h₁ ▸ as) := sorry
example {α β h} (h₁ : α = β) (as : List α) (P : List β → Type) : P (h ▸ as) := sorry
example (h₁ : α = β) (as : List α) (P : List β → Type) : P (h ▸ as) := sorry
set_option relaxedAutoImplicit false in
example (h₁ : α = β) (as : List α) (P : List β → Type) : P (hi ▸ as) := sorry