Skip to content

Add __traits isDynamicArray - #23803

Open
nordlow wants to merge 1 commit into
dlang:masterfrom
nordlow:add-more-traits
Open

Add __traits isDynamicArray#23803
nordlow wants to merge 1 commit into
dlang:masterfrom
nordlow:add-more-traits

Conversation

@nordlow

@nordlow nordlow commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Partially resolves #23784.

I can split the PR up into two if requested.

Changelog will be updated if this gets approved.

Looking into failing tests.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

DMD perf check

Metric Base PR Δ
dmd binary size (stripped) 6.86 MB 6.88 MB +0.28%
All measurements
Metric Base PR Δ
compile hello.d (instr) 215.1 M 215.1 M -0.001%
compile hello.d -O -release (instr) 233.4 M 233.4 M +0.002%
compile Phobos (instr) 5,120.9 M 5,120.8 M -0.002%
compile Phobos codegen (instr) 1,472.4 M 1,472.4 M -0.004%
compile vibe.d (instr) 15,113.8 M 15,112.9 M -0.006%
dmd binary size (stripped) 6.86 MB 6.88 MB +0.28%
hello binary size (stripped) 0.72 MB 0.72 MB 0.00%
peak RSS (compile hello.d) 43.48 MB 43.51 MB +0.07%
peak RSS (compile Phobos) 617.2 MB 620.0 MB +0.45%
peak RSS (compile vibe.d) 1916 MB 1918 MB +0.09%
compile dmd itself (wall) 12.1 s 12.1 s +0.33%
compile hello.d (wall) 64.1 ms 63.7 ms -0.62%
compile Phobos (wall) 1,545 ms 1,549 ms +0.26%

4c2c3be vs merge-base 86b74e2 · about these metrics

@ntrel

ntrel commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

runnable/traits.d TEST_OUTPUT needs updating.

@dkorpel

dkorpel commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What's the rationale for isArray and why is an Associative Array not one?

@dkorpel

dkorpel commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

From the issue

Please do not allow this trait to accept enums!

This PR's implementation accepts enums

@nordlow

nordlow commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

What's the rationale for isArray and why is an Associative Array not one?

Good point. I agree that isArray should be true for AAs.

Update: I removed isArray from this PR.

@nordlow

nordlow commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

From the issue

Please do not allow this trait to accept enums!

This PR's implementation accepts enums

Shouldn't we mimic the behavior __traits(isStaticArray, ...) in this case? Despite it accepting enums is a bad design.

And then later disallow all traits of this kind to not accept enums?

For the sake of consistency.

I'm ok with both alternatives.

@dkorpel

dkorpel commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Good point. I agree that isArray should be true for AAs.

That's not what I meant, I don't see why it needs to exist in the first place. What's the real world use case?

@nordlow

nordlow commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Good point. I agree that isArray should be true for AAs.

That's not what I meant, I don't see why it needs to exist in the first place. What's the real world use case?

I don't know.

@nordlow

nordlow commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

compiler/test/run.d runnable/traits.d now passes locally for me.

@nordlow nordlow changed the title Add __traits isDynamicArray and isArray Add __traits isDynamicArray Sep 9, 2026
@nordlow

nordlow commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

What's the rationale for isArray and why is an Associative Array not one?

Removed isArray changes from this PR.

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.

Add is-expression or __traits for Dynamic Arrays

3 participants