http://d.puremagic.com/issues/show_bug.cgi?id=2887

           Summary: Wrong line number reported inside string mixin
           Product: D
           Version: 1.041
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzi...@digitalmars.com
        ReportedBy: cbkbbej...@mailinator.com


----------
import tango.io.Stdout;
template line()
{
        const char[] line = "__LINE__";
}
template wrongLine()
{
        const char[] wrongLine = "\n\n\n\n\n__LINE__";
}
void main()
{
        Stdout.formatln("Line: {}, {}, {}", __LINE__, mixin(line!()),
mixin(wrongLine!()));
        Stdout.formatln("Line: {}, {}, {}", __LINE__, mixin(line!()),
mixin(wrongLine!()));
}
----------

Expected output:
Line: 12, 12, 12
Line: 13, 13, 13

Actual output:
Line: 12, 12, 17
Line: 13, 13, 18

DMD is reporting the line where __LINE__ *would* be *after* mixin expansion.
However, this only hinders the programmer rather than helping because the
programmer isn't actually working with the post-expansion code. Therefore, when
__LINE__ appears inside a string mixin, it should resolve to the line number of
the mixin instantiation.

This is preventing my custom assert routines from automatically reporting the
correct line number of the assertion, and is thus forcing my custom assert
routines to require the user to manually pass in __LINE__.


-- 

Reply via email to