[SAoC2022] Replace libdparse with dmd-as-a-library in D-Scanner

user1234 user1234 at 12.de
Wed Dec 14 15:43:53 UTC 2022


On Tuesday, 13 December 2022 at 17:31:46 UTC, Lucian Danescu 
wrote:
> Hello!
>
> [...]
>>Here is an example of "troublesome" code for this check:
> ```
> void f()
> {
>     version (Windows)
>         int a;
>
>     static if (true)
>         version (POSIX)
>             int a;
>         else
>             int b;
> }
> ```
> My implementation would wrongly issue a warning in this 
> scenario. If anyone would have any suggestions on how to go 
> about this it would be awesome.

The dparse-based implementation assumes that the version 
condition are awlays true and in consequence it ignores 
everything that's declared in the "else" blocks. You must have 
missed something in the DMDFE version of the AST but to be fair 
at first glance your translation looks faithful.

But in any case the way it works now is not correct either so I'd 
advice to skip entirely static conditions and versions. It will 
be possible to handle these two cases the day the semantics will 
be run.


More information about the Digitalmars-d mailing list