Skip to content

Commit 51ed5f2

Browse files
authored
fix: register node kind for elabToSyntax functionality (#11235)
This PR registers a node kind for `Lean.Parser.Term.elabToSyntax` in order to support the `Lean.Elab.Term.elabToSyntax` functionality without registering a dedicated parser for user-accessible syntax.
1 parent 1759b83 commit 51ed5f2

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Lean/Elab/Term/TermElabM.lean

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -771,20 +771,20 @@ def withMacroExpansion [Monad n] [MonadControlT TermElabM n] (beforeStx afterStx
771771
withPushMacroExpansionStack beforeStx afterStx <| runInBase x
772772

773773
/--
774-
Reference a fixed term elaborator by index.
775-
This syntax should never be constructed directly; rather it is an implementation detail of
776-
`Lean.Elab.Term.elabToSyntax`.
774+
Node kind for the `Lean.Elab.Term.elabToSyntax` functionality.
775+
It is an implementation detail of `Lean.Elab.Term.elabToSyntax`.
777776
-/
778-
protected def _root_.Lean.Parser.Term.fixedTermElab := leading_parser
779-
Lean.Parser.Term.num
777+
protected def _root_.Lean.Parser.Term.elabToSyntax : Unit := ()
778+
779+
builtin_initialize Lean.Parser.registerBuiltinNodeKind ``Lean.Parser.Term.elabToSyntax
780780

781781
/-- Refer to the given term elaborator by a scoped `Syntax` object. -/
782782
def elabToSyntax (fixedTermElab : FixedTermElab) (k : Term → TermElabM α) : TermElabM α := do
783783
let ctx ← read
784784
withReader (fun ctx => { ctx with fixedTermElabs := ctx.fixedTermElabs.push fixedTermElab.toFixedTermElabRef }) do
785-
k ⟨mkNode ``Lean.Parser.Term.fixedTermElab #[Syntax.mkNatLit ctx.fixedTermElabs.size]⟩
785+
k ⟨mkNode ``Lean.Parser.Term.elabToSyntax #[Syntax.mkNatLit ctx.fixedTermElabs.size]⟩
786786

787-
@[builtin_term_elab Lean.Parser.Term.fixedTermElab] def elabFixedTermElab : TermElab := fun stx expectedType? => do
787+
@[builtin_term_elab Lean.Parser.Term.elabToSyntax] def elabFixedTermElab : TermElab := fun stx expectedType? => do
788788
let some idx := stx[0].isNatLit? | throwUnsupportedSyntax
789789
let some fixedTermElab := (← read).fixedTermElabs[idx]?
790790
| throwError "Fixed term elaborator {idx} not found. There were only {(← read).fixedTermElabs.size} fixed term elaborators registered."

0 commit comments

Comments
 (0)