File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed
Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -172,14 +172,21 @@ def registerTagAttribute (name : Name) (descr : String)
172172
173173namespace TagAttribute
174174
175+ /-- Sets the attribute (without running `validate`) -/
176+ def setTag [Monad m] [MonadError m] [MonadEnv m] (attr : TagAttribute) (decl : Name) : m Unit := do
177+ let env ← getEnv
178+ unless (env.getModuleIdxFor? decl).isNone do
179+ throwError "invalid attribute '{attr.attr.name}', declaration {.ofConstName decl} is in an imported module"
180+ unless env.asyncMayContain decl do
181+ throwError "invalid attribute '{attr.attr.name}', declaration {.ofConstName decl} is not from the present async context {env.asyncPrefix?}"
182+ modifyEnv fun env => attr.ext.addEntry env decl
183+
175184def hasTag (attr : TagAttribute) (env : Environment) (decl : Name) : Bool :=
176185 match env.getModuleIdxFor? decl with
177186 | some modIdx => (attr.ext.getModuleEntries env modIdx).binSearchContains decl Name.quickLt
178187 | none =>
179- -- TODO: Is findStateAsync not always correct?
180188 if attr.ext.toEnvExtension.asyncMode matches .async then
181- (attr.ext.findStateAsync env decl).contains decl ||
182- (attr.ext.getState env (asyncMode := .local)).contains decl
189+ (attr.ext.findStateAsync env decl).contains decl
183190 else
184191 (attr.ext.getState env).contains decl
185192
Original file line number Diff line number Diff line change @@ -67,6 +67,4 @@ def inferRflAttr (declName : Name) : MetaM Unit := do
6767 else
6868 pure false
6969 if isRfl then
70- unless (← getEnv).asyncMayContain declName do
71- throwError "inferRflAttr: declaration {.ofConstName declName} is not from the present async context {(← getEnv).asyncPrefix?}"
72- modifyEnv fun env => rflAttr.ext.addEntry env declName
70+ rflAttr.setTag declName
You can’t perform that action at this time.
0 commit comments