[Issue 18543] Comments inside string mixin silently short-circuit code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 1 13:58:02 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18543

Andrea Fontana <trikkuz at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trikkuz at gmail.com

--- Comment #1 from Andrea Fontana <trikkuz at gmail.com> ---
Just because you're mixin a single line.
Adding \n will solve the problem

import std.stdio;

void main(string[] args)
{
    mixin(""
    ~"writeln(\"Hello\");"
    ~"// Some comment\n"                                                        
    ~"assert(0);"
    );  
}

your code sounds like:

void main()
{
    writeln("hello"); // Some comment assert(0)
}

--


More information about the Digitalmars-d-bugs mailing list