August 08, 2023
https://issues.dlang.org/show_bug.cgi?id=24047

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--- Comment #1 from Dennis <dkorpel@live.nl> ---
unittests are not being parsed without -unittest by design

> I believe the code above should not compile, even when -unittest is not specified.

Why?

--
August 08, 2023
https://issues.dlang.org/show_bug.cgi?id=24047

--- Comment #2 from Steven Schveighoffer <schveiguy@gmail.com> ---
> Why?

The grammar specifies "BlockStatement", not "GarbageWithSomeBraceMatching"

The result is surprising to say the least. I don't know what is saved by doing an alternate grammar parsing, but I doubt it's worth it. This basically says that the D compiler is not a valid parser of the D grammar unless the -unittest switch is enabled.

A good test would be to parse (but not compile) std.datetime, which is full of
unittests, and compare the performance (memory and speed) and see if it's worth
it.

Would it be really bad to at least expect an opening brace as the next token? That shouldn't be too expensive. I'm not sure how much parser state can be kept without generating AST to validate the grammar, but it just feels wrong to have invalid syntax pass the parser.

--