lean4-htt/tests/lean/1275.lean.expected.out
Sebastian Ullrich 51bba5338a
perf: make macro scope numbering less dependent on surrounding context (#10027)
This PR changes macro scope numbering from per-module to per-command,
ensuring that unrelated changes to other commands do not affect macro
scopes generated by a command, which improves `prefer_native` hit rates
on bootstrapping as well as avoids further rebuilds under the module
system.

In detail, instead of always using the current module name as a macro
scope prefix, each command now introduces a new macro scope prefix
(called "context") of the shape `<main module>._hygCtx_<uniq>` where
`uniq` is a `UInt32` derived from the command but automatically
incremented in case of conflicts (which must be local to the current
module). In the current implementation, `uniq` is the hash of the
declaration name, if any, or else the hash of the full command's syntax.
Thus, it is always independent of syntactic changes to other commands
(except in case of hash conflicts, which should only happen in practice
for syntactically identical commands) and, in the case of declarations,
also independent of syntactic changes to any private parts of the
declaration.
2025-08-22 13:16:02 +00:00

22 lines
646 B
Text

fun x => do
let info ← MonadRef.mkInfoFromRefPos
let scp ← getCurrMacroScope
let quotCtx ← MonadQuotation.getContext
pure
{
raw :=
Syntax.node2 info `«term👉__» (Syntax.atom info "👉")
x.raw } : (x : TSyntax [`ident, `token._]) → ?m x (TSyntax `term)
true
true
fun x => do
let info ← MonadRef.mkInfoFromRefPos
let scp ← getCurrMacroScope
let quotCtx ← MonadQuotation.getContext
pure
{
raw :=
Syntax.node2 info `termBarBazBoing (Syntax.atom info "bar")
x.raw } : (x : TSyntax [`token.baz, `token.boing]) → ?m x (TSyntax `term)
true
true