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

Lucian Danescu lucidanescu28 at yahoo.com
Tue Dec 13 17:31:46 UTC 2022


Hello!
​
Since my last update I created 2 pull requests for new visitors:
  - [auto_func](https://github.com/Dlang-UPB/D-scanner/pull/59)
  - 
[backwards_range](https://github.com/Dlang-UPB/D-scanner/pull/58)

And did some refactoring for 
[static_if_else](https://github.com/Dlang-UPB/D-scanner/pull/56)

Also created these pull requests in `dmd` adding 
`isStaticIfCondtion` method, and fixing
a minor bug in `TemplateDeclaration` constructor in `ASTBase`
- [isStaticIfCondition](https://github.com/dlang/dmd/pull/14689)
- [template_constructor](https://github.com/dlang/dmd/pull/14691)

I also encountered some difficulties for 2 particular checks:

1. I think I already mentioned this a while back but still I 
didn't manage to get it straight so I am mentioning this again. 
[This](https://github.com/Dlang-UPB/D-scanner/blob/replace_libdparse/src/dscanner/analysis/label_var_same_name_check.d) is a visitor that checks if a variable name shadow another variable from an outer scope. The problems come from `static if` and `version` conditions, as these do not introduce a new scope, and for me at least it is not yet 100% clear how to treat them, as things get really complicated when we have many `static if` mixed with `version`. 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.
This is the [pr](https://github.com/Dlang-UPB/D-scanner/pull/41) 
where I tried a few different implementations for that. Feel free 
to leave a comment :)

2. Second issue I ran into would be regarding `@property` 
functions with no arguments that should be marked `const`. In 
order not to extend this post even more please check 
[this](https://github.com/dlang/phobos/pull/8648) out for more 
explanations regarding why that check could be problematic.


Thank you!


More information about the Digitalmars-d mailing list