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
Mark if(__ctfe) blocks as SCOPEctfe #3572
Conversation
Allows e.g. allocating in an if(__ctfe) block in a @nogc function
ping @k-hara @WalterBright |
Not a bad idea. But since it is an enhancement, it needs a bugzilla entry for it. It also apparently needs to be rebased. |
@jpf91 @WalterBright A blocker issue of this idea is that currently the special variable __ctfe could appear everywhere.
Therefore, compiler cannot determine the CTFE-specific code branch in semantic analysis stage. An easy way to resolve the issue is, that defining the statement |
@WalterBright OK. A little background: I've hacked gdc to report all GC allocations to completely remove the GC dependencies from druntime. I'll use that for a first port to the NintendoDS were our GC probably wouldn't work. And there's some code in druntime which uses this |
@9rnsr you're right about this being a kludge that doesn't work in the general case. Your solution has a lot of merit - and I think it merits a wider discussion. We need a bugzilla entry and a newsgroup discussion on it. |
BTW, other unconsidered cases include:
where do we stop? |
The form of conditional expression |
Probably at function border? |
So... what's the status of this? Fix? Close? Please advise. |
I suggest close, however remind me again. Why isn't |
Ah right, because the false branch would always be removed. |
Closing for #7509 |
More readable message in ArrayIndexError
Allows e.g. allocating in an if(__ctfe) block in a @nogc function