__FILE__ and __LINE__ in case of import expression
Steven Schveighoffer
schveiguy at gmail.com
Fri Aug 21 15:34:49 UTC 2020
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.
-Steve
More information about the Digitalmars-d-learn
mailing list