lean4-htt/tests/lean/run/439.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

55 lines
972 B
Text

set_option pp.mvars false
universe u
structure Fn (E I : Sort u) := (exp : E) (imp : I)
instance (E I : Sort u) : CoeFun (Fn E I) (fun _ => I) := {coe := fun K => K.imp}
class Bar.{w} (P : Sort u) :=
fn : P -> Sort w
variable {P : Sort u} (B : Bar P)
variable (fn : Fn ((p : P) -> B.fn p) ({p : P} -> B.fn p))
#check (@fn : {p : P} → Bar.fn p) -- Result is as expected (implicit)
/-
fn.imp : {p : P} → Bar.fn p
-/
variable (p : P)
variable (Bp : Bar.fn p)
/--
error: function expected at
fn.imp
term has type
Bar.fn ?_
-/
#guard_msgs in
#check fn Bp
/--
error: function expected at
fn.imp
term has type
Bar.fn ?_
-/
#guard_msgs in
#check fn p
#check fn (p := p)
variable (fn' : Fn ((p : P) -> B.fn p -> B.fn p) ({p : P} -> B.fn p -> B.fn p))
#check fn' Bp
/--
error: Application type mismatch: In the application
fn'.imp p
the argument
p
has type
P : Sort u
but is expected to have type
Bar.fn ?_ : Sort _
-/
#guard_msgs in
#check fn' p