Skip to content

change hasIndirections!void to true for consistency with TypeInfo - #22593

Merged
thewilsonator merged 1 commit into
dlang:masterfrom
schveiguy:void-has-pointers
Feb 20, 2026
Merged

thewilsonator merged 1 commit into
dlang:masterfrom
schveiguy:void-has-pointers

Conversation

@schveiguy

@schveiguy schveiguy commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

See issue #22517

An alternative fix considered was to special case void arrays in the array allocator. However, TypeInfo_v (void typeinfo) reports that it contains pointers. You can't create a variable of type void, only arrays of void, so this shouldn't affect any existing code except to fix bugs (which assumed the same behavior from hasIndirections!void as typeid(void).flags() as the array runtime did).

pinging @jmdavis as you added tests that needed to be reversed in #20813 last year. I'm assuming the tests added were for completeness, based on current behavior instead of an expectation of that behavior. If I'm wrong, please explain the thought behind the test.

@dlang-bot

Copy link
Copy Markdown

Thanks for your pull request, @schveiguy!

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.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

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 + dmd#22593"

@schveiguy

Copy link
Copy Markdown
Member Author

@CyberShadow can you explain the failure in ae here and whether this points to a bug, or a misunderstanding of mine on hasIndirections?

@CyberShadow

CyberShadow commented Feb 19, 2026 •

Copy link
Copy Markdown
Member

The friction is coming from:

  1. std.file - std.file.read returns void[]. This defines that void[] is the correct type for "data from a file"; types have bubbled stemming from this decision throughout libraries, ae included.
  2. void[] may contain pointers (because T*[] is implicitly convertible to void[]).

I think at this point it's clear that 1 was the wrong call. std.file.read should return ubyte[] (implicitly flagged as unique).

Practically speaking, I can adjust ae to use ubyte[] there, and start pushing back on 1 - it already does this in other parts anyway.

@schveiguy

Copy link
Copy Markdown
Member Author

I think at this point it's clear that 1 was the wrong call. std.file.read should return ubyte[] (implicitly flagged as unique).

Yeah, I think that choice has impacted many over the years. I was curious about the implementation, and at least as far back as 12 years ago, the line inside std.file that allocates the array was:

void[] result = uninitializedArray!(ubyte[])(initialAlloc);

Allocating a ubyte[] and then casting to void[]. should have just been ubyte[] all along.

CyberShadow added a commit to CyberShadow/ae that referenced this pull request Feb 19, 2026
Rationale:

- void[] is unsuitable for raw data, as the language assumes it may
  contain pointers. An upcoming dmd change makes hasIndirections!void
  return true for consistency with TypeInfo, which means that void[]
  will no longer work where pointer-free types are expected.

  See: dlang/dmd#22593

Changes required:

- Switch to using ubyte[] to represent "data from a file" instead of
  void[], or add casts where appropriate when calling iconv, sha1sum,
  or parseViaIMConvert.
@Herringway

Copy link
Copy Markdown
Contributor

The friction is coming from:

1. `std.file` - `std.file.read` returns `void[]`. This defines that `void[]` is the correct type for "data from a file"; types have bubbled stemming from this decision throughout libraries, `ae` included.

2. `void[]` may contain pointers (because `T*[]` is implicitly convertible to `void[]`).

I think at this point it's clear that 1 was the wrong call. std.file.read should return ubyte[] (implicitly flagged as unique).

I cannot possibly express just how strongly I agree with this.

@CyberShadow

Copy link
Copy Markdown
Member

I tagged a new ae version (which passes a local digger run master+dmd#22593 -- dub test) so re-running BuildKite should bake it green[er].

@schveiguy

Copy link
Copy Markdown
Member Author

Thanks, now passing

@thewilsonator
thewilsonator merged commit 9decd49 into dlang:master Feb 20, 2026
39 checks passed
@schveiguy
schveiguy deleted the void-has-pointers branch February 20, 2026 13:11
petewil0 pushed a commit to petewil0/dmd that referenced this pull request Feb 24, 2026
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.

5 participants