dot ident pattern does not treat parameters as inaccessible
@kmill is already working on this.
Since Aug 24, 2025.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
Please put an X between the brackets as you perform the following steps:
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - Reduce the issue to a minimal, self-contained, reproducible test case.
Avoid dependencies to Mathlib or Batteries. - Test your test case against the latest nightly release, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
When elaborating a constructor pattern, the parameters are treated as inaccessible.
example : List α → Bool
| List.nil (α := α) => false
| List.cons (α := α) .. => true
In this example, (α := α) is equivalent to (α := .(α)) and does not bind a new variable. However, switching to the dot ident notation does not have this behavior, causing the example to fail.
example : List α → Bool
| .nil (α := α) => false
| .cons (α := α) .. => true
Context
This difference in behavior is relied upon in a mathlib test:
https://github.com/leanprover-community/mathlib4/blob/a7fc949f1b05c2a01e01c027fd9f480496a1253e/MathlibTest/congr.lean#L176-L181
Changing the pattern .nil n to walk.nil n causes it to no longer succeed.
Steps to Reproduce
Run the code above with the dot ident notation.
Expected behavior: No errors, same as the code which uses the full constructor name.
Actual behavior: The following error:
type mismatch
[]
has type
List α : Type ?u.19
but is expected to have type
List α✝ : Type ?u.9
Versions
Lean 4.16.0-nightly-2025-01-07
This bug has been present since the introduction of the dot ident feature in e1fa9c1
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.