[Issue 2887] New: Wrong line number reported inside string mixin

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Apr 24 12:19:27 PDT 2009


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: bugzilla at digitalmars.com
        ReportedBy: cbkbbejeap at 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__.


-- 



More information about the Digitalmars-d-bugs mailing list