The subst notation substitues in the expected type, if present, or in the type of the argument, if no expected type is known. If there is an expected type it already fails if it cannot find the equations' left hand side or right hand side. But if the expected type is not known and the equation's lhs is not present in the second argument's type, it will happily do a no-op-substitution. This is inconsistent and unlikely what the user intended to do, so we now print an error message now. This still only looks for the lhs; search for the rhs as well seems prudent, but I’ll leave that for a separate PR, to better diagnose the impact on mathlib. This triggers a small number of pointless uses of subst in mathlib, see https://github.com/leanprover-community/mathlib4/pull/12451
46 lines
1.4 KiB
Text
46 lines
1.4 KiB
Text
substFails.lean:5:67-5:74: error: invalid `▸` notation, expected result type of cast is
|
|
P 4
|
|
however, the equality
|
|
heq
|
|
of type
|
|
foo = bar
|
|
does not contain the expected result type on either the left or the right hand side
|
|
substFails.lean:7:67-7:74: error: invalid `▸` notation, the equality
|
|
heq
|
|
has type
|
|
foo = bar
|
|
but its left hand side is not mentioned in the type
|
|
P 3
|
|
substFails.lean:8:67-8:74: error: invalid `▸` notation, expected result type of cast is
|
|
P 4
|
|
however, the equality
|
|
heq
|
|
of type
|
|
foo = bar
|
|
does not contain the expected result type on either the left or the right hand side
|
|
substFails.lean:11:67-11:74: error: invalid `▸` notation, the equality
|
|
heq
|
|
has type
|
|
bar = foo
|
|
but its left hand side is not mentioned in the type
|
|
P foo
|
|
substFails.lean:12:67-12:74: error: invalid `▸` notation, expected result type of cast is
|
|
P 4
|
|
however, the equality
|
|
heq
|
|
of type
|
|
bar = foo
|
|
does not contain the expected result type on either the left or the right hand side
|
|
substFails.lean:14:67-14:74: error: invalid `▸` notation, the equality
|
|
heq
|
|
has type
|
|
bar = foo
|
|
but its left hand side is not mentioned in the type
|
|
P 3
|
|
substFails.lean:15:67-15:74: error: invalid `▸` notation, expected result type of cast is
|
|
P 4
|
|
however, the equality
|
|
heq
|
|
of type
|
|
bar = foo
|
|
does not contain the expected result type on either the left or the right hand side
|