Skip to content

transpile: make TypedAstContext::macro_{invocations,expansions,expansion_test} into IndexMaps instead of HashMaps#1334

Merged
kkysen merged 1 commit intomasterfrom
kkysen/macro-IndexMaps
Aug 21, 2025
Merged

transpile: make TypedAstContext::macro_{invocations,expansions,expansion_test} into IndexMaps instead of HashMaps#1334
kkysen merged 1 commit intomasterfrom
kkysen/macro-IndexMaps

Conversation

@kkysen
Copy link
Copy Markdown
Contributor

@kkysen kkysen commented Aug 21, 2025

Previously, macro_invocations was a HashMap, and thus iterating through it was unordered, which populated the Vec<CExprId> of macro_expansions non-deterministically, which then resulted in non-deterministic output from --translate-const-macros conservative.

I also changed the other macro_* maps to IndexMap, as many other maps in TypedAstContext are already IndexMaps, too, and it's likely that we want these stably ordered and deterministic.

@kkysen kkysen requested a review from fw-immunant August 21, 2025 00:03
Copy link
Copy Markdown
Contributor Author

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

@fw-immunant, I think you previously said this looked good, so if you could review quickly and we can merge it, that'd be great. I don't want #1306 to get too large, so I'd like to merge the simpler parts of it first.

…sion_test}` into `IndexMap`s instead of `HashMap`s

Previously, `macro_invocations` was a `HashMap`, and thus iterating through it was unordered,
which populated the `Vec<CExprId>` of `macro_expansions` non-deterministically,
which then resulted in non-deterministic output from `--translate-const-macros conservative`.

I also changed the other `macro_*` maps to `IndexMap`,
as many other maps in `TypedAstContext` are already `IndexMap`s, too,
and it's likely that we want these stably ordered and deterministic.
@kkysen kkysen force-pushed the kkysen/macro-IndexMaps branch from b9834b2 to 3eec9fa Compare August 21, 2025 06:13
@kkysen kkysen changed the base branch from master to kkysen/remove-x86_64-macos August 21, 2025 06:14
Copy link
Copy Markdown
Contributor

@fw-immunant fw-immunant left a comment

Choose a reason for hiding this comment

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

It seems like the target branch should be master, but this change does seem reasonable.

Base automatically changed from kkysen/remove-x86_64-macos to master August 21, 2025 19:15
Copy link
Copy Markdown
Contributor Author

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

It seems like the target branch should be master, but this change does seem reasonable.

It was #1337 just to speed up CI as I was rebasing a lot and running a lot of slow CI jobs. It points into master now.

@kkysen kkysen merged commit 834db06 into master Aug 21, 2025
5 checks passed
@kkysen kkysen deleted the kkysen/macro-IndexMaps branch August 21, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants