lean4-htt/tests/lean/run/4670.lean
jrr6 995fa4766b
fix: reduce ambiguity of "final" in application type mismatch message (#8322)
This PR refines the new wording of the "application type mismatch" error
message to avoid ambiguity in references to the "final" argument in a
subexpression that may be followed by additional arguments.

It does so by replacing "final" with "last," rephrasing the message so
that this adjective modifies the argument itself rather than the word
"argument," and only displaying this wording when two arguments could be
confused (determined by expression equality).

These changes were motivated by a report that in cases where a function
application `f a b c` fails to elaborate because `b` is incorrectly
typed, the existing error message's reference to `b` being the "final"
argument in the application `f a b` may create confusion because it is
not the final argument in the full application expression.
2025-05-14 16:12:10 +00:00

62 lines
1.2 KiB
Text

/-!
# Check types when pretty printing dot notation for structure projections
In type mismatch errors, the 'object of dot notation' might not be valid for dot notation.
-/
structure Foo : Type where
out : Nat
/-!
Was printing `true.out`, but it should have been `Foo.out true`.
-/
/--
error: Application type mismatch: In the application
Foo.out true
the argument
true
has type
Bool : Type
but is expected to have type
Foo : Type
---
info: sorry.out : Nat
-/
#guard_msgs in #check Foo.out true
/-!
Verifying that generalized field notation does not have this bug.
-/
def Foo.out' (f : Foo) : Nat := f.out
/--
error: Application type mismatch: In the application
Foo.out' true
the argument
true
has type
Bool : Type
but is expected to have type
Foo : Type
---
info: sorry.out' : Nat
-/
#guard_msgs in #check Foo.out' true
/-!
Verifying that projection notation still pretty prints as normal.
-/
section
variable (f : Foo)
/-- info: f.out : Nat -/
#guard_msgs in #check f.out
end
/-!
Verifying that projection notation still pretty prints through type synonys.
-/
section
def Baz := Foo
variable (f : Baz)
/-- info: f.out : Nat -/
#guard_msgs in #check f.out
end