Skip to content

fix: run @[init] declarations in declaration order#12221

Merged
Kha merged 2 commits intoleanprover:masterfrom
Kha:push-tmwkmlnpntuw
Jan 29, 2026
Merged

fix: run @[init] declarations in declaration order#12221
Kha merged 2 commits intoleanprover:masterfrom
Kha:push-tmwkmlnpntuw

Conversation

@Kha
Copy link
Copy Markdown
Member

@Kha Kha commented Jan 28, 2026

Fixes #10175 harder.

@Kha Kha added the changelog-no Do not include this PR in the release changelog label Jan 28, 2026
Copy link
Copy Markdown
Contributor

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, perhaps worth noting that this fixes #10175 again.

Comment on lines +273 to +274
let r := m.foldl (fun a n p => a.push (n, p)) #[]
r.qsort (fun a b => Name.quickLt a.1 b.1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to sort, also why not use toArray?

Suggested change
let r := m.foldl (fun a n p => a.push (n, p)) #[]
r.qsort (fun a b => Name.quickLt a.1 b.1)
(m : Std.TreeMap Name α Name.quickCmp).toArray

Comment on lines +5 to +8
private initialize ref3 : Unit ← ref.modify (·.push "ref3")
initialize ref2 : Unit ← ref.modify (·.push "ref2")
initialize ref1 : Unit ← ref.modify (·.push "ref1")
private initialize ref4 : Unit ← ref.modify (·.push "ref4")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps worth adding

#guard (fun a => a.qsort (Name.quickLt) ≠ a) #[`ref3, `ref2, `ref1, `ref4]

before the test, to ensure that we didn't happen to pick names which hash in order.

@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Jan 28, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-01-28 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-01-28 22:27:31)

ghost pushed a commit to leanprover-community/batteries that referenced this pull request Jan 28, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Jan 28, 2026
ghost pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jan 28, 2026
@ghost
Copy link
Copy Markdown

ghost commented Jan 28, 2026

Mathlib CI status (docs):

@ghost ghost added the builds-mathlib CI has verified that Mathlib builds against this PR label Jan 28, 2026
@Kha Kha enabled auto-merge January 29, 2026 15:16
@Kha Kha added this pull request to the merge queue Jan 29, 2026
Merged via the queue into leanprover:master with commit 892cbe2 Jan 29, 2026
17 checks passed
@Kha Kha deleted the push-tmwkmlnpntuw branch February 6, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-no Do not include this PR in the release changelog mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@[init] declarations are sometimes run in the wrong order

4 participants