-
-
Notifications
You must be signed in to change notification settings - Fork 608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
recognize if(__ctfe) blocks #14913
recognize if(__ctfe) blocks #14913
Conversation
|
Thanks for your pull request, @WalterBright! 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. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#14913" |
918e609
to
523ecb4
Compare
887dad5
to
0550051
Compare
|
This is ready to go. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo in a followup: deal with unnecessary generation of TypeInfo's in betterC.
This needs to be elaborated as to how it will be done, preferably with the change in question ready in another PR so we get the context rather than a piecemeal of the design.
As it currently stands, this and #14830 will just be reverted in 2 days.
|
#14830 solves the problem of calls to new and TypeInfo having code being generated for them, despite being it __ctfe blocks. It's the equivalent solution ldc and gdc use. It solves an actual bug, is simple, and causes no known problems. It would a shame to revert it. This PR resolves the issue of being able to call the GC in a __ctfe block despite the function being @nogc or -betterC. It works and none of the other attempts at it work. It also prevents the suppression of emitting code for functions in betterC code that only calls the GC inside a __ctfe block. The next PR relies on this one, and extends it to prevent the generation of TypeInfo from code within a __ctfe block. It both requires this PR, and is not any sort of conceptual leap over it. |
It caused a regression, what else do you expect to happen? |
Merge the fix #14916 |
So now |
Why? |
0550051
to
67d5f28
Compare
I can't think of a good analogy, but it's not about the use of the rule, rather the growing list of exceptions that must be remembered for that rule. One alternative to consider, what about |
The logic that goto cannot jump into a ctfe block is the same as that used to prevent jumping into a try block, scope block, and jumping past declarations.
Since existing code already uses |
That would also be an exception to remember. |
This is a partial solution to https://issues.dlang.org/show_bug.cgi?id=18472
It turns out to be necessary to properly recognize
if (__ctfe)code blocks because different semantics apply. That's what this PR does. It takes advantage of it by:gotofrom entering a ctfe blockTodo in a followup: deal with unnecessary generation of TypeInfo's in betterC.