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

Lucian Danescu lucidanescu28 at yahoo.com
Sat Nov 19 20:39:14 UTC 2022


Hello!

Since the last update I implemented the following visitors:
- 
[auto_ref_assignment](https://github.com/Dlang-UPB/D-scanner/pull/51)
- 
[assert_without_msg](https://github.com/Dlang-UPB/D-scanner/pull/50)

Also finished the work on 
[explicitly_annotated_unittests](https://github.com/Dlang-UPB/D-scanner/pull/44),
did one more iteration for 
[constructor_check](https://github.com/Dlang-UPB/D-scanner/pull/43) as it
was in need of a redesign and spent a good amount of time on
[same_name_check](https://github.com/Dlang-UPB/D-scanner/pull/41). This visitor is not 100% correct in the
actual `D-Scanner`. A small example would be this:

```
static if(true)
     int a;
else
{
     int a;
     int a; // should throw a warning but doesn't
}
```

```
static if(true)
	int a = 2;

static if(true)
	int a = 2; // throws warning

static if(true)
	enum a = 2;

static if(true)
	enum a = 2; // does not throw warning
```

Things can get a bit tricky here with conditional declarations, 
because
they don't introduce a new scope, and you can't really always 
evaluate them,
meaning we can have situations like:

```
version(windows)
     int a;
version(something_not_windows)
     int a; // will incorrectly throw a warning
```

I decided with my mentors to go ahead and mimic the actual 
implementation,
even if it's not 100% correct, and I will probably get back to it 
at a later
point.

Also created a small [pr](https://github.com/dlang/dmd/pull/14646)
in dmd adding some lacking methods in `ASTBase`

Thank you!


More information about the Digitalmars-d mailing list