On 8/21/20 4:54 PM, Andrey Zherikov wrote:
On Friday, 21 August 2020 at 20:44:27 UTC, Andrey Zherikov wrote:
Thanks for this link! I can use "#line" to fix line number but not
file name:
file: 'foo.d-mixin-1', line: '6', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] args)',
file full path: 'C:\Users\andrey\foo.d-mixin-1'
I can actually fix this issue as well.
Changes in test.d:
test(); // line #16 (1)
mixin("#line 1 \"foo.d\"\n" ~ import("foo.d")); // line #17 (2)
test(); // line #18 (3)
Output:
file: 'test.d', line: '16', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] args)',
file full path: 'C:\Users\andrey\test.d'
file: 'foo.d', line: '6', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] args)',
file full path: 'C:\Users\andrey\foo.d'
file: 'test.d', line: '18', module: 'test',
function: 'test.main', pretty function: 'int test.main(string[] args)',
file full path: 'C:\Users\andrey\test.d'
Was just in the process of responding with this technique!
I think what you probably did first is:
int main(string[] args)
{
test();
#line 1 "foo.d"
mixin(import("foo.d"));
return 0;
}
Which sets the line and file of test.d at that point. But when the mixin
happens, I believe the parser/lexer sets the filename, but does not set
the line number to something different.
The hybrid line number (original source line number + mixin line number)
seems like a bug to me.
-Steve