[Issue 2887] Wrong line number reported inside string mixin
https://issues.dlang.org/show_bug.cgi?id=2887 Iain Buclaw changed: What|Removed |Added Priority|P2 |P3 --
[Issue 2887] Wrong line number reported inside string mixin
https://issues.dlang.org/show_bug.cgi?id=2887 Seb changed: What|Removed |Added CC||greensunn...@gmail.com Version|D1 (retired)|D2 --- Comment #3 from Seb --- Changing this to D2 as it's still not working as expected: --- template line() { const char[] line = "__LINE__"; } template wrongLine() { const char[] wrongLine = "\n\n\n\n\n__LINE__"; } void main() { import std.stdio; writefln("Line: %s, %s, %s", __LINE__, mixin(line!()), mixin(wrongLine!())); writefln("Line: %s, %s, %s", __LINE__, mixin(line!()), mixin(wrongLine!())); } --- https://run.dlang.io/is/uZrbxu --
[Issue 2887] Wrong line number reported inside string mixin
http://d.puremagic.com/issues/show_bug.cgi?id=2887 --- Comment #2 from Nick Sabalausky 2009-09-07 13:25:54 PDT --- Workaround: template foo() { const char[] foo = `{ auto __foo_line = __LINE__; // must be on first line // Also, the extra surrounding {} is needed to // allow foo to be used twice in the same scope. Stdout.formatln("Foo:"); Stdout.formatln(" File {}", __FILE__); Stdout.formatln(" Line {}", __foo_line); }`; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email --- You are receiving this mail because: ---
[Issue 2887] Wrong line number reported inside string mixin
http://d.puremagic.com/issues/show_bug.cgi?id=2887 --- Comment #1 from shro8...@vandals.uidaho.edu 2009-04-24 14:38 --- What I think it should do is the filename inside a mixin should be (based on outside values): __FILE__:__LINE__ and the line number should restart at 1 so that you can get both inside and outside info even with several levels of mixins Another option would be to have a __LINES__ macro that is an array of line numbers for each level of mixins. __LINES__[$-2] == __LINE__ at mixin() --