leanprover / leanprover/lean4

dot ident pattern does not treat parameters as inaccessible

Open
#6,570 0 comments 1 reaction 1 assignee View on GitHub

@kmill is already working on this.

Since Aug 24, 2025.

bug P-medium
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:

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.