Skip to content

Commit

Permalink
feat: reactivate extendJoinPointContext at mono phase
Browse files Browse the repository at this point in the history
closes #1686

cc @hargoniX
  • Loading branch information
leodemoura committed Oct 7, 2022
1 parent 15ad525 commit 4597422
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Lean/Compiler/LCNF/JoinPoints.lean
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def Decl.extendJoinPointContext (decl : Decl) : CompilerM Decl := do
JoinPointContextExtender.extend decl

def extendJoinPointContext : Pass :=
.mkPerDeclaration `extendJoinPointContext Decl.extendJoinPointContext .base
.mkPerDeclaration `extendJoinPointContext Decl.extendJoinPointContext .mono

builtin_initialize
registerTraceClass `Compiler.extendJoinPointContext (inherited := true)
Expand Down
4 changes: 4 additions & 0 deletions src/Lean/Compiler/LCNF/Passes.lean
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def builtinPassManager : PassManager := {
cse,
saveBase, -- End of base phase
toMono,
simp (occurrence := 3) (phase := .mono),
reduceJpArity (phase := .mono),
extendJoinPointContext,
simp (occurrence := 4) (phase := .mono),
-- TODO: lambda lifting, reduce function arity
saveMono -- End of mono phase
]
Expand Down
4 changes: 2 additions & 2 deletions src/Lean/Compiler/LCNF/ReduceJpArity.lean
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def Decl.reduceJpArity (decl : Decl) : CompilerM Decl := do
let value ← reduce decl.value |>.run {}
return { decl with value }

def reduceJpArity : Pass :=
.mkPerDeclaration `reduceJpArity Decl.reduceJpArity .base
def reduceJpArity (phase := Phase.base) : Pass :=
.mkPerDeclaration `reduceJpArity Decl.reduceJpArity phase

builtin_initialize
registerTraceClass `Compiler.reduceJpArity (inherited := true)
Expand Down
4 changes: 2 additions & 2 deletions src/Lean/Compiler/LCNF/Simp.lean
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ where
else
return decl

def simp (config : Config := {}) (occurrence : Nat := 0) : Pass :=
.mkPerDeclaration `simp (Decl.simp · config) .base (occurrence := occurrence)
def simp (config : Config := {}) (occurrence : Nat := 0) (phase := Phase.base) : Pass :=
.mkPerDeclaration `simp (Decl.simp · config) phase (occurrence := occurrence)

builtin_initialize
registerTraceClass `Compiler.simp (inherited := true)
Expand Down
7 changes: 7 additions & 0 deletions tests/lean/run/1686.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Lean
open Lean Meta

def substIssue (hLocalDecl : LocalDecl) : MetaM Unit := do
let error {α} _ : MetaM α := throwError "{hLocalDecl.type}"
let some (_, lhs, rhs) ← matchEq? hLocalDecl.type | error ()
error ()

0 comments on commit 4597422

Please sign in to comment.