Skip to content

Commit

Permalink
fix elaboration code
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeizer committed Dec 18, 2024
1 parent 583858e commit 13dd278
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions Qpf/Macro/Data.lean
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ def mkHeadT (view : InductiveView) : CommandElabM Name := do
}

withQPFTraceNode "elabInductiveViews" <|
elabInductiveViews #[view]
runTermElabM <| fun vars =>
elabInductiveViews vars #[view]
pure declName

open Parser Parser.Term Parser.Command in
Expand Down Expand Up @@ -358,7 +359,8 @@ def mkShape (view : DataView) : TermElabM MkShapeResult := do
return ⟨r, declName, PName, do
withQPFTraceNode "mkShape effects" <| do

elabInductiveViews #[view]
runTermElabM <| fun vars =>
elabInductiveViews vars #[view]

let headTName ← mkHeadT view
let childTName ← mkChildT view r headTName
Expand Down Expand Up @@ -444,7 +446,7 @@ open Macro Comp in
def elabData : CommandElab := fun stx =>
withQPFTraceNode "elabData" (tag := "elabData") (collapsed := false) <| do

let modifiers ← elabModifiers stx[0]
let modifiers ← elabModifiers stx[0]
let decl := stx[1]

let view ← dataSyntaxToView modifiers decl
Expand Down
7 changes: 3 additions & 4 deletions Qpf/Macro/Data/View.lean
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,11 @@ def dataSyntaxToView (modifiers : Modifiers) (decl : Syntax) : CommandElabM Data
let (binders, type?) := expandOptDeclSig decl[2]

let declId : TSyntax ``declId := ⟨decl[1]⟩
let ⟨name, declName, levelNames⟩ ← expandDeclId declId modifiers
addDeclarationRanges declName decl
let ⟨name, declName, levelNames⟩ ← expandDeclId (← getCurrNamespace) (← getLevelNames) declId modifiers
-- addDeclarationRanges declName decl
let ctors ← decl[4].getArgs.mapM fun ctor => withRef ctor do
-- def ctor := leading_parser optional docComment >> "\n| " >> declModifiers >> rawIdent >> optDeclSig
let mut ctorModifiers ← elabModifiers ctor[2]
let mut ctorModifiers ← elabModifiers ctor[2]
if let some leadingDocComment := ctor[0].getOptional? then
if ctorModifiers.docString?.isSome then
logErrorAt leadingDocComment "duplicate doc string"
Expand All @@ -289,7 +289,6 @@ def dataSyntaxToView (modifiers : Modifiers) (decl : Syntax) : CommandElabM Data
let ctorName ← withRef ctor[3] $ applyVisibility ctorModifiers.visibility ctorName
let (binders, type?) := expandOptDeclSig ctor[4]
addDocString' ctorName ctorModifiers.docString?
addAuxDeclarationRanges ctorName ctor ctor[3]
return { ref := ctor, modifiers := ctorModifiers, declName := ctorName, binders := binders, type? := type? : CtorView }
let classes ← liftCoreM <| getOptDerivingClasses decl[5]

Expand Down

0 comments on commit 13dd278

Please sign in to comment.