fix: inconsistent inaccessible annotations
This commit is contained in:
parent
660c49840f
commit
b4a7d28cff
2 changed files with 23 additions and 26 deletions
|
|
@ -9,6 +9,15 @@ import Lean.Meta.Match.CaseArraySizes
|
|||
|
||||
namespace Lean.Meta.Match
|
||||
|
||||
/--
|
||||
Auxiliary annotation used to mark terms marked with the "inaccessible" annotation `.(t)` and
|
||||
`_` in patterns. -/
|
||||
def mkInaccessible (e : Expr) : Expr :=
|
||||
mkAnnotation `_inaccessible e
|
||||
|
||||
def inaccessible? (e : Expr) : Option Expr :=
|
||||
annotation? `_inaccessible e
|
||||
|
||||
inductive Pattern : Type where
|
||||
| inaccessible (e : Expr) : Pattern
|
||||
| var (fvarId : FVarId) : Pattern
|
||||
|
|
@ -36,7 +45,7 @@ where
|
|||
match p with
|
||||
| inaccessible e =>
|
||||
if annotate then
|
||||
pure (mkAnnotation `inaccessible e)
|
||||
pure (mkInaccessible e)
|
||||
else
|
||||
pure e
|
||||
| var fvarId => pure $ mkFVar fvarId
|
||||
|
|
@ -256,15 +265,6 @@ structure MatcherResult where
|
|||
counterExamples : List CounterExample
|
||||
unusedAltIdxs : List Nat
|
||||
|
||||
/--
|
||||
Auxiliary annotation used to mark terms marked with the "inaccessible" annotation `.(t)` and
|
||||
`_` in patterns. -/
|
||||
def mkInaccessible (e : Expr) : Expr :=
|
||||
mkAnnotation `_inaccessible e
|
||||
|
||||
def inaccessible? (e : Expr) : Option Expr :=
|
||||
annotation? `_inaccessible e
|
||||
|
||||
/--
|
||||
Convert a expression occurring as the argument of a `match` motive application back into a `Pattern`
|
||||
For example, we can use this method to convert `x::y::xs` at
|
||||
|
|
|
|||
|
|
@ -265,23 +265,20 @@ def delabAppMatch : Delab := whenPPOption getPPNotation do
|
|||
|
||||
@[builtinDelab mdata]
|
||||
def delabMData : Delab := do
|
||||
-- only interpret `pp.` values by default
|
||||
let Expr.mdata m _ _ ← getExpr | unreachable!
|
||||
let mut posOpts := (← read).optionsPerPos
|
||||
let mut inaccessible := false
|
||||
let pos := (← read).pos
|
||||
for (k, v) in m do
|
||||
if (`pp).isPrefixOf k then
|
||||
let opts := posOpts.find? pos |>.getD {}
|
||||
posOpts := posOpts.insert pos (opts.insert k v)
|
||||
if k == `inaccessible then
|
||||
inaccessible := true
|
||||
withReader ({ · with optionsPerPos := posOpts }) do
|
||||
if let some _ := Lean.Meta.Match.inaccessible? (← getExpr) then
|
||||
let s ← withMDataExpr delab
|
||||
if inaccessible then
|
||||
`(.($s))
|
||||
else
|
||||
pure s
|
||||
`(.($s))
|
||||
else
|
||||
-- only interpret `pp.` values by default
|
||||
let Expr.mdata m _ _ ← getExpr | unreachable!
|
||||
let mut posOpts := (← read).optionsPerPos
|
||||
let pos := (← read).pos
|
||||
for (k, v) in m do
|
||||
if (`pp).isPrefixOf k then
|
||||
let opts := posOpts.find? pos |>.getD {}
|
||||
posOpts := posOpts.insert pos (opts.insert k v)
|
||||
withReader ({ · with optionsPerPos := posOpts }) do
|
||||
withMDataExpr delab
|
||||
|
||||
/--
|
||||
Check for a `Syntax.ident` of the given name anywhere in the tree.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue