phobos icon indicating copy to clipboard operation
phobos copied to clipboard

fix issue 23140

Open RubyTheRoobster opened this issue 1 year ago • 7 comments

Thanks for your pull request and interest in making D better, @RubyTheRoobster! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
23140 regression Array!T where T is a shared class no longer works

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 "stable + phobos#8526"

dlang-bot avatar Aug 03 '22 15:08 dlang-bot

This needs a test to show that it works.

schveiguy avatar Aug 04 '22 00:08 schveiguy

I added the tests. And they do fail under the current dmd.

RubyTheRoobster avatar Aug 04 '22 01:08 RubyTheRoobster

Not sure but Unshared could be added to std.traits?

Tynukua avatar Aug 04 '22 09:08 Tynukua

Not sure but Unshared could be added to std.traits?

It could, but it really doesn't make sense: the Unshared template is used to take a type, whether shared or not, and convert it to the unshared version. On the other hand, I was told in this forum post (from which I got the idea) that it was a private template in std.traits.

Unrelated, but shouldn't this PR be marked as regression?

RubyTheRoobster avatar Aug 04 '22 12:08 RubyTheRoobster

I just realized (from looking at Ali's slides for dconf) that std.traits has a template called Unqual, that removes ALL qualifiers, not just shared.

Edit: For some reason, using Unqal doesn't work, and the compiler spews a thousand errors, so I'm sticking to Unshared.

RubyTheRoobster avatar Aug 04 '22 17:08 RubyTheRoobster

This still fails:

const class C {} // or immutable
Array!C ac;

in fact this has always failed:

class C {}
Array!(const C) ac;

I don't know the internals of Array but I think a more appropriate fix is to only cast away modifiers on memory-related calls and let the type system flow at a higher level, like when using Array.opIndex. Your patch removes shared from the type system (for Array!(shared C) ac, ac[0] is not shared).

BorisCarvajal avatar Aug 08 '22 23:08 BorisCarvajal

There is a regression that as of now prevents me from going any further, and could be related to the pull request that caused this one.

Edit: I have found a work around, but it involves Unshared. Hopefully this single usage doesn't result in breaking the type system.

RubyTheRoobster avatar Aug 10 '22 15:08 RubyTheRoobster

So the assert statement on line 1416 is failing, and I honestly can't figure out why.

RubyTheRoobster avatar Aug 10 '22 19:08 RubyTheRoobster

As for const and immutable classes, that's another issue unrelated to this one caused by std.algorithm.mutate.move not supporting them.

Still, that doesn't prevent me from looking into fixing them.

RubyTheRoobster avatar Aug 10 '22 20:08 RubyTheRoobster