Skip to content

Do implicit cast for ExpInitializers inside CTFE#3602

Merged
WalterBright merged 1 commit into
dlang:masterfrom
don-clugston-sociomantic:ctfe_implicit_convert
May 30, 2014
Merged

Do implicit cast for ExpInitializers inside CTFE#3602
WalterBright merged 1 commit into
dlang:masterfrom
don-clugston-sociomantic:ctfe_implicit_convert

Conversation

@donc
Copy link
Copy Markdown
Collaborator

@donc donc commented May 28, 2014

When a manifest constant is initialized using CTFE, the initializer may perform an implicit cast of the CTFE return value, and then run CTFE again. This commit moves the implicit cast into the initial CTFE whenever possible. This means that CTFE immediately calculates the final value of the expression.

One beneficial side-effect of this is that it allows implicit conversion of unique CTFE values to immutable, so one test moves from fails_compilation to compiles.

Move the implicit cast inside CTFE, so that we're evaluating the
final value.
@donc
Copy link
Copy Markdown
Collaborator Author

donc commented May 28, 2014

This PR requires PR #3594.

WalterBright added a commit that referenced this pull request May 30, 2014
Do implicit cast for ExpInitializers inside CTFE
@WalterBright WalterBright merged commit 2260a96 into dlang:master May 30, 2014
@CyberShadow
Copy link
Copy Markdown
Member

After this pull, this code no longer works (array cast from string[] to immutable(char[][]) is not supported at compile time):

enum E { a }
immutable string[] splitterNames = [EnumMembers!E].map!(e => e.text()).array();

Is that a regression?

@CyberShadow
Copy link
Copy Markdown
Member

ibuclaw pushed a commit to ibuclaw/dmd that referenced this pull request Jul 10, 2022
Add OpenBSD-specific *alloc prototypes.
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.

4 participants