Using a string generated at compile-time in a @nogc function

Anonymouse via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun May 1 03:37:23 PDT 2016


On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote:
> Hi all,
>
> I'm working on removing the string mixins from my code, but 
> have run into an issue:
>
> http://dpaste.dzfl.pl/ecd7eb53947e
>
> As far as I can tell, this should work; the enum should force 
> compile-time execution (which it does, as evidenced by the 
> pragma). [...]

That does seem buggy but I don't know enough to say for certain. 
I'd suggest filing a bug report anyway; the worst thing that can 
happen is that it gets closed. Unreported bugs can only be fixed 
by accident.

Tacking an .idup after .toLower seems to make it work, at least 
on dpaste (http://dpaste.dzfl.pl/8abed3d3ec6c). I would have 
thought both toLower and idup returned a normal string, but 
unsure.

>         enum loweredName = member.to!string.toLower.idup;
>         pragma(msg, loweredName);
>
>         if (member == test)
>             return loweredName;


More information about the Digitalmars-d-learn mailing list