On Friday, 21 August 2020 at 15:34:49 UTC, Steven Schveighoffer wrote:
On 8/21/20 10:01 AM, Andrey Zherikov wrote:
How can I get __FILE__ and __LINE__ values correct in case of import expression?
...

So the output from line #16 (1) is correct although from line #17 (2) is not: file name is neither 'test.d' not 'foo.d' and line number is 22 although both test.d and foo.d are shorter.

You can override the filename and line number to the lexer: https://dlang.org/spec/lex.html#special-token-sequence

vibe.d does this so when errors from the trans-piled diet files happen, they match (mostly) back to the diet file, not the source file where they are mixed in.

I understand that I can create a workaround but want to check first whether this is desired behavior or a bug that should be fixed?

That's a good question. I would say it should say line 17 or line 6 (preferably the latter). That may be considered a bug, I don't know.

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'

Reply via email to