In patterns, ellipsis should always fill in each remaining argument as an implicit argument, even if it is an optparam or autoparam. This prevents examples such as the one in #4555 from failing: ```lean match e with | .internal .. => sorry | .error .. => sorry ``` The `internal` constructor has an optparam (`| internal (id : InternalExceptionId) (extra : KVMap := {})`). We may consider having ellipsis suppress optparams and autoparams in general. We avoid doing so for now since it's possible to opt-out of them individually (for example with `.internal (extra := _) ..`) but it's not possible to opt-in, and it is plausible that `..` with optparams is useful in contexts such as the `refine` tactic. With patterns however, it is hard to imagine a use case that offsets the inconvenience of optparams being eagerly supplied. Closes #4555
16 lines
332 B
Text
16 lines
332 B
Text
import Lean.Exception
|
|
/-!
|
|
# In pattern, `..` shouldn't make use of opt-params
|
|
|
|
https://github.com/leanprover/lean4/issues/4555
|
|
-/
|
|
|
|
open Lean
|
|
|
|
/-!
|
|
The `.internal` constructor has an opt-param, which caused this to be a non-exhaustive match.
|
|
-/
|
|
example (e : Exception) : Nat :=
|
|
match e with
|
|
| .internal .. => 0
|
|
| .error .. => 1
|