Fix Issue 18493 - [betterC] Can't use aggregated type with postblit#2184
Fix Issue 18493 - [betterC] Can't use aggregated type with postblit#2184dlang-bot merged 1 commit intodlang:masterfrom JinShil:betterC_nothrow
Conversation
|
Thanks for your pull request, @JinShil! Bugzilla references
|
src/object.d
Outdated
| { | ||
| extern (C) Object _d_newclass(const TypeInfo_Class ci); | ||
| extern (C) void rt_finalize(void *data, bool det=true); | ||
| nothrow: |
There was a problem hiding this comment.
This doesn't work (attributes in a version block don't apply to the outer scope).
There was a problem hiding this comment.
Thanks. What's the proper idiom, then?
There was a problem hiding this comment.
I don think that there is one. I tried something along the lines of :
import std.stdio: writeln;
version(V1)
{
enum versionl = true;
}
else
{
}
static if (versionl)
{
notrow:
}
void f()
{
writeln("bla");
}But it doesn't work since it looks like nothrow: cannot be placed inside a static if body. If static if doesn't work and nothrow: inside a version body does not work for the outer scope I see no other solution then to actually declare the code as a string and mixin it in each branch. I hope that someone has a better idea, cause the one I proposed is awful.
There was a problem hiding this comment.
You could put the optionally nothrow code into a template mixin, and mixin the template on each leaf of the version statement.
There was a problem hiding this comment.
You could put the optionally nothrow code into a template mixin, and mixin the template on each leaf of the version statement.
Oh, man, that would be great if it worked. Please illustrate with an example, as I don't quite follow. You can see my prior attempts here: https://forum.dlang.org/post/uhgzgmowqcczczrdtsol@forum.dlang.org
EDIT: scratch that. You're right. It works. Awesome.
|
I Removed the auto-merge label. This needs a solution to the
|
|
@WalterBright, I'm sorry for interrupting the workflow. I got a little confused since you objected to the DMD PR, but approved this. I see now that this PR has value regardless of the fate of the DMD PR. I also implemented your elegant solution to the conditional attribute problem. It turns out, however, it wasn't needed because the templated code has its attributes inferred by the caller. Nevertheless, since this idiom was hard-won, I left the boiler-plate in place so, if we find code that needs this conditional attribution, we know where to put it. I predict this code will need to be added to and enhanced as we continue to implement -betterC. Please give it another look. Once this is merged, I should be able to address https://issues.dlang.org/show_bug.cgi?id=18905 with more predicatable results. |
|
#2194 Should be merged first. It has the same changes as this PR, but removes the controversy around the |
|
#2194 took care of the excessive importing. This PR is now only needed to support dlang/dmd#8253. |
|
@WalterBright I'm seeing some strange undefined reference errors in the Circle CI tests. I think they're related to backend conversion to D. Any ideas? |
You'll need to upgrade the D host compiler (or remove -betterC from the command line for dvec.d). |
Done. #2205 |
|
Ping! Why hasn't this merged? |
This PR is required for dlang/dmd#8253. Please read the motivation there for context.
Despite the enabling features this provides for dlang/dmd#8253, this PR is still quite useful and forward-looking.Although -betterC does not link with druntime or phobos, it still imports object.d. There is a large amount of code in object.d that not utilized when compiling with -betterC, but it is notversioned out like it should be, and that causes the compiler to emit errors for code that isn't even being utilized. This is not only necessary for dlang/dmd#8253, but also for other planned -betterC features like enabling the use of classes with onlystaticmembers (See dlang/dmd#8204 for an already merged PR enabling this for minimal runtime builds).It is likely future PRs will need to be made to hoist certain templates out of theversion(Not_BetterC)area up to theversion(D_BetterC)` area as users utilize -betterC more and file issues identifying certain language features that don't work in a -betterC environment. It will also be beneficial to acquire those issue reports to identify lapses in test coverage for -betterC.EDIT: #2194 took care of the excessive importing. This PR is now only needed to support dlang/dmd#8253.