Thread overview
[Issue 23883] `#line` is off by one and off by two if a line comment follows
May 05, 2023
RazvanN
May 09, 2023
Bolpat
May 11, 2023
RazvanN
May 05, 2023
https://issues.dlang.org/show_bug.cgi?id=23883

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
The #line directive needs to be terminated by a newline or EOF. In your example the newline is commented, therefore whatever comes next after the comment on the exact following line has to be a newline or EOF so that the directive is correctly lexed.

I think that the best way to proceed here is to add a spec mention about this as fixing will add unnecessary complexity (checking for comments before the directive ends) to support an unlikely corner case.

--
May 09, 2023
https://issues.dlang.org/show_bug.cgi?id=23883

--- Comment #2 from Bolpat <qs.il.paperinik@gmail.com> ---
So, you’re suggesting that we make a bug a feature. Checking for comments before the directive ends isn’t that big of a deal.

You don’t even have to handle it correctly, you can make it an error if that is easier. It’s surprising, and you shouldn’t surprise users.

--
May 11, 2023
https://issues.dlang.org/show_bug.cgi?id=23883

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
(In reply to Bolpat from comment #2)
> So, you’re suggesting that we make a bug a feature. Checking for comments before the directive ends isn’t that big of a deal.
> 

No, I am saying that this is such niche case (why would you attach comments to line directives?) that it doesn't really warrant the complexity added in the lexer.

But I understand your point of view, that's why I'm leaving this bug report open.

> You don’t even have to handle it correctly, you can make it an error if that is easier. It’s surprising, and you shouldn’t surprise users.

--