Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/Lean/Elab/DeclModifiers.lean
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,6 @@ def Modifiers.isPartial : Modifiers → Bool
| { recKind := .partial, .. } => true
| _ => false

/--
Whether the declaration is explicitly `partial` or should be considered as such via `meta`. In the
latter case, elaborators should not produce an error if partiality is unnecessary.
-/
def Modifiers.isInferredPartial : Modifiers → Bool
| { recKind := .partial, .. } => true
| { computeKind := .meta, .. } => true
| _ => false

def Modifiers.isNonrec : Modifiers → Bool
| { recKind := .nonrec, .. } => true
| _ => false
Expand Down
24 changes: 6 additions & 18 deletions src/Lean/Elab/PreDefinition/Main.lean
Original file line number Diff line number Diff line change
Expand Up @@ -329,25 +329,13 @@ def addPreDefinitions (docCtx : LocalContext × LocalInstances) (preDefs : Array
else if preDefs.any (·.modifiers.isUnsafe) then
addAndCompileUnsafe docCtx preDefs
preDefs.forM (·.termination.ensureNone "unsafe")
else if preDefs.any (·.modifiers.isPartial) then
for preDef in preDefs do
if preDef.modifiers.isPartial && !(← whnfD preDef.type).isForall then
withRef preDef.ref <| throwError "invalid use of `partial`, `{preDef.declName}` is not a function{indentExpr preDef.type}"
addAndCompilePartial docCtx preDefs
preDefs.forM (·.termination.ensureNone "partial")
else
-- Consider partial if `partial` was given explicitly, or implied and no termination hint
-- was given
if preDefs.any (·.modifiers.isPartial) ||
preDefs.any (·.modifiers.isInferredPartial) && !preDefs.any (·.termination.isNotNone) then
let mut isPartial := true
for preDef in preDefs do
if !(← whnfD preDef.type).isForall then
if preDef.modifiers.isPartial then
withRef preDef.ref <| throwError "invalid use of `partial`, `{preDef.declName}` is not a function{indentExpr preDef.type}"
else
-- `meta` should not imply `partial` in this case
isPartial := false

if isPartial then
addAndCompilePartial docCtx preDefs
preDefs.forM (·.termination.ensureNone "partial")
continue

ensureFunIndReservedNamesAvailable preDefs
try
checkCodomainsLevel preDefs
Expand Down
Loading