Add more traits doc examples & make existing examples runnable#2507
Add more traits doc examples & make existing examples runnable#2507dlang-bot merged 4 commits intodlang:masterfrom
Conversation
|
Thanks for your pull request, @n8sh! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
e64ecf9 to
845eebd
Compare
|
LGTM, but whats with DAutoTest? Looks like some of those examples are not compilable? |
84d3065 to
b9df4a2
Compare
spec/traits.dd
Outdated
| $(P This array can be used by a precise GC to avoid false pointers.) | ||
| $(SPEC_RUNNABLE_EXAMPLE_COMPILE | ||
| --- | ||
| class C |
There was a problem hiding this comment.
This gets a void main wrapped around it, thus making it nested adding an extra pointer to it, throwing off the size calculations. Easiest to just remove it.
There was a problem hiding this comment.
The SPEC_RUNNABLE_EXAMPLE_COMPILE that is.
There was a problem hiding this comment.
No please don't remove it. Better fix the script or you know use static
There was a problem hiding this comment.
Adding static at what appears to be the top level would be confusing. I think maybe the best thing is to wrap this with a fake main and include static.
676da01 to
e060844
Compare
| writeln(__traits(getMember, s, "m" ~ "x")); // 1 | ||
|
|
||
| __traits(getMember, S, "mx") = 1; // error, no this for S.mx | ||
| // __traits(getMember, S, "mx") = 1; // error, no this for S.mx |
There was a problem hiding this comment.
Add a __traits(compiles)?
| @@ -985,6 +1127,7 @@ void main() | |||
| test(); | |||
There was a problem hiding this comment.
alias tests = Tuple!(__traits(getUnitTests, foo));
static assert(tests.length == 1);Why is this failing?
There was a problem hiding this comment.
Oh, it's because the example isn't compiled with -unittest.
|
Added a commit that changes example code to be compiled with |
|
This is to make the __traits(getUnitTests) example compilable.
dabfb45 to
a033b1a
Compare
The motivation for the new examples is to demonstrate:
__vectors have the same traits as their element type.enums have the same traits as the underlying type.Also made most of the existing code examples runnable while I was at it.