leanprover / leanprover/lean4

Unclear error message when pattern matching on ambiguous notation

Open
#2,050 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug error message P-medium
Dominant language
Lean
Stars
9.2k
Forks
990
Avg merge
1d 17h
Merged PRs (30d)
175

Description

notation a " :: " b => Fin.add a b
#check [42] matches _ :: _
/-
bug.lean:2:20: error: invalid pattern, constructor or constant marked with '[match_pattern]' expected
-/

FWIW, this used to work in Lean 3:

notation (name := fincons) a `::` b := fin.add a b
#check show nat, from match [42] with | x::xs := 1 | _ := 0 end

(This came up in mathlib with the Sym.cons' function.)

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.

Research direction

Start by reproducing the example in bug.lean and compare it with the included Lean 3 notation example. Trace how the notation a :: b => Fin.add a b is handled during pattern matching, then verify that the ambiguous-notation case produces a clearer diagnostic or the intended matching behavior.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.