Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swap-and-destroy called too eagerly #8950

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

WalterBright
Copy link
Member

The error exhibits as:

std/typecons.d(984): Error: none of the overloads of template `std.algorithm.mutation.swap` are callable using argument types `!(Tuple!(ubyte, uint))(Tuple!(ubyte, uint), Tuple!(immutable(ubyte), uint))`
std/algorithm/mutation.d(2840):        Candidates are: `swap(T)(ref T lhs, ref T rhs)`
std/algorithm/mutation.d(3102):                        `swap(T)(ref T lhs, ref T rhs)`
  with `T = Tuple!(ubyte, uint)`
  must satisfy the following constraint:
       `is(typeof(lhs.proxySwap(rhs)))`
iteration.d(69): Error: template instance `std.typecons.Tuple!(ubyte, uint).Tuple.opAssign!(Tuple!(immutable(ubyte), uint))` error instantiating
iteration.d(13):        instantiated from here: `Group!("a == b", immutable(ubyte)[])`
iteration.d(109):        instantiated from here: `group!("a == b", immutable(ubyte)[])`

triggered by dlang/dmd#16314 and is blocking it.

The trouble is Tuple.opAssign() selects swap-and-destroy when one of the arguments is const/mutable/shared, and so cannot be assigned to. This fix causes the opAssign branch to be taken instead.

The test case is a bit difficult to come up with, as it comes with 16384.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @WalterBright!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + phobos#8950"

@WalterBright WalterBright merged commit 41716f8 into dlang:master Mar 20, 2024
10 checks passed
@WalterBright WalterBright deleted the swapAndDestroy branch March 20, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants