diff --git a/src/Init/Data/List/ToArrayImpl.lean b/src/Init/Data/List/ToArrayImpl.lean index 3cde4c8036..fce7ae0249 100644 --- a/src/Init/Data/List/ToArrayImpl.lean +++ b/src/Init/Data/List/ToArrayImpl.lean @@ -31,6 +31,6 @@ both `List.toArray` and `Array.mk`. -/ -- This function is exported to C, where it is called by `Array.mk` -- (the constructor) to implement this functionality. -@[inline, match_pattern, pp_nodot, export lean_list_to_array] +@[inline, expose, match_pattern, pp_nodot, export lean_list_to_array] def List.toArrayImpl (xs : List α) : Array α := xs.toArrayAux (Array.mkEmpty xs.length) diff --git a/src/Lean/Elab/Tactic/Do/ProofMode/MGoal.lean b/src/Lean/Elab/Tactic/Do/ProofMode/MGoal.lean index 3b5d4ac1f0..ff83c723a5 100644 --- a/src/Lean/Elab/Tactic/Do/ProofMode/MGoal.lean +++ b/src/Lean/Elab/Tactic/Do/ProofMode/MGoal.lean @@ -19,8 +19,8 @@ namespace Lean.Elab.Tactic.Do.ProofMode open Lean Elab Meta open Std.Do Std.Tactic.Do -@[match_pattern] def nameAnnotation := `name -@[match_pattern] def uniqAnnotation := `uniq +@[match_pattern] private def nameAnnotation := `name +@[match_pattern] private def uniqAnnotation := `uniq structure Hyp where name : Name diff --git a/src/Lean/Meta/Match/MatchPatternAttr.lean b/src/Lean/Meta/Match/MatchPatternAttr.lean index e46e41c8bd..a9d856e350 100644 --- a/src/Lean/Meta/Match/MatchPatternAttr.lean +++ b/src/Lean/Meta/Match/MatchPatternAttr.lean @@ -33,6 +33,10 @@ def isYellow (color : String) : Bool := @[builtin_doc] builtin_initialize matchPatternAttr : TagAttribute ← registerTagAttribute `match_pattern "mark that a definition can be used in a pattern (remark: the dependent pattern matching compiler will unfold the definition)" + (validate := fun declName => do + withExporting (isExporting := !isPrivateName declName) do + if !(← getConstInfo declName).isDefinition then + throwError "invalid `@[match_pattern]` attribute, '{declName}' is not an exposed definition") @[export lean_has_match_pattern_attribute] def hasMatchPatternAttribute (env : Environment) (n : Name) : Bool :=