Repository navigation
Conversation
Recursive equality attribute inference can fail depending on compiler source-file order, as reported in dlang/dmd#24202. This affects algebraic variants containing Annotated or AnnotatedOnce alternatives. Explicitly declare pure, nothrow, and @nogc on both wrappers' equality methods when the wrapped type is a Mir algebraic variant, whose equality already guarantees those attributes. Preserve attribute inference for other wrapped types. Add regression coverage for nested equality, differing annotations and values, const receivers, and calls requiring all three attributes. Verify that wrappers around effectful custom types retain their original attribute restrictions. AI-Assisted-By: Codex (GPT-6 Astra Medium)
jmh530
marked this pull request as ready for review
November 4, 2026 15:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Compiling recursive algebraic values containing
AnnotatedorAnnotatedOncecan fail attribute checking depending on compiler source-file order. This surfaced during a Redub build of mir-algorithm; replaying the compiler command independently reproduced the failure.The underlying DMD frontend issue is tracked in dlang/dmd#24202. This PR provides a library workaround.
Changes
Explicitly declare
pure nothrow @nogconAnnotatedandAnnotatedOnceequality whenisVariant!Tis true. Mir algebraic equality already guarantees these attributes, so stating them on the wrappers breaks the recursive inference cycle.Other wrapped types retain the existing inferred attributes. The equality expressions remain unchanged.
Add regression tests for both wrappers covering nested values, matching and differing annotations and payloads, mutable and const receivers, and equality calls requiring all three attributes. Additional checks verify that wrappers around a custom type whose equality allocates, throws, and modifies shared state do not incorrectly acquire these attributes.
Validation
Using mir-core 1.7.4:
mir_testenabled.unittest-ciconfiguration passed.git diff --checkpassed.Remote CI, macOS tests, and the complete Linux package suite remain to be verified. This workaround addresses Mir algebraic types; it does not resolve attribute inference for arbitrary user-defined recursive wrappers.
AI-Assisted-By: Codex (GPT-6 Astra Medium)