Thread overview
[Issue 16445] string mixin allows shebang line in source
Aug 29, 2016
Cauterite
Aug 30, 2016
b2.temp@gmx.com
Aug 30, 2016
Cauterite
Mar 21, 2020
Basile-z
Dec 17, 2022
Iain Buclaw
August 29, 2016
https://issues.dlang.org/show_bug.cgi?id=16445

Cauterite <cauterite@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--
August 30, 2016
https://issues.dlang.org/show_bug.cgi?id=16445

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from b2.temp@gmx.com ---
Yes that's funny. I've tried to understand why this is accepted. If you compile this

°°°°°a.d°°°°°°
enum t = "#line 1\n#!a";
mixin(t);
August 30, 2016
https://issues.dlang.org/show_bug.cgi?id=16445

--- Comment #2 from Cauterite <cauterite@gmail.com> ---
(In reply to b2.temp from comment #1)
> So there is no bug. The shebang is removed as specified. You can also see that if you add a space before, an error is emitted.

Well the bug is that shebang lines aren't applicable to string mixins, because they're not executed from a shell, so they should be a syntax error regardless. Especially if the mixin is an expression, where accepting a shebang line makes no sense whatsoever.

The lexer has only one constructor, and it always strips "#!…\n" off
unconditionally:
https://github.com/dlang/dmd/blob/fb64019c2251d5f447967b9e796de8afc76e6226/src/lexer.d#L187

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=16445

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=16445

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
December 13
https://issues.dlang.org/show_bug.cgi?id=16445

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17773

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--