Bug 14660 – std.range.choose() is not CTFE'able

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-06-07T07:09:50Z
Last change time
2018-01-02T00:58:39Z
Assigned to
No Owner
Creator
Walter Bright

Comments

Comment #0 by bugzilla — 2015-06-07T07:09:50Z
The trouble is caused by the use of the void[] buffer, which is cast to the right type, and the cast fails in CTFE.
Comment #1 by greeenify — 2016-03-04T12:59:22Z
Hmm I tried to hack it with: ``` alias CT = CommonType!(ElementType!(Unqual!R1), ElementType!(Unqual!R2)); ``` It works well for the runtime, but in CTFE one still gets `cast from int* to int[]* is not supported`. Using CT[] compiles in CTFE, but returns garbage.
Comment #2 by ali.akhtarzada — 2018-01-01T23:07:12Z
Is there a workaround for this hidden in someone's head? I.e. anyway around the void[] buffer, or is it viable to allow casts in CTFE to make this succeed?
Comment #3 by greensunny12 — 2018-01-01T23:29:29Z
No workaround needed, just use dmd-nightly or the upcoming 2.078 release (will be released in the next hours or tomorrow). Example: https://run.dlang.io/is/ss9U1c This was fixed in https://github.com/dlang/phobos/pull/5677, but wasn't referenced (hence no changelog nor auto-closing of this issue).
Comment #4 by ali.akhtarzada — 2018-01-02T00:58:39Z
Sweet! Thanks!