Thread overview
[SAoC2022] Replace libdparse with dmd-as-a-library in D-Scanner week 3
Oct 09, 2022
Lucian Danescu
Oct 09, 2022
Dom Disc
Oct 09, 2022
user1234
Oct 10, 2022
Lucian Danescu
Oct 10, 2022
Johan
Oct 11, 2022
user1234
October 09, 2022

Hello!

This week I added initial implementations for the following visitor:
incorrect_infinite_range

Made the additions necessary so that the parser is compatible with ASTBase also:
ErrorExp and
ErrorStatement and completed a pull request
fixing a location issue

Since the latest pull requests were merged into dmd, I could run tests and ran into this
situation:

Let's consider this code

static class C
{
    // ...
    final void foo() { ... }
    // ...
}

So in D-Scanner we have a check that warns against redundant usage of final keyword.
Final is indeed redundant with static methods, but with the current D-Scanner implementation,
in the example above the usage of final is not signaled, while with my implementation it is.
I would have a question here, and that would be if I should stick 100% with the current behavior
of D-Scanner, or if I should update the behavior, as I would say is the case here, and probably
similar situations will arise in the future.

October 09, 2022

On Sunday, 9 October 2022 at 16:05:32 UTC, Lucian Danescu wrote:

>

should I stick 100% with the current behavior
of D-Scanner, or if I should update the behavior, as I would say is the case here, and probably
similar situations will arise in the future.

I would say, raise a bugzilla issue, and propose your implemenation as a fix to it. That would at least document the change.
Only if the issue is discarded as WONTFIX (i.e. it is intended), you should stick 100% with the current behavior.

October 09, 2022

On Sunday, 9 October 2022 at 16:05:32 UTC, Lucian Danescu wrote:

>

Hello!

[...]

Let's consider this code

static class C
{
    // ...
    final void foo() { ... }
    // ...
}

So in D-Scanner we have a check that warns against redundant usage of final keyword.
Final is indeed redundant with static methods, but with the current D-Scanner implementation,
in the example above the usage of final is not signaled, while with my implementation it is.

D-Scanner is right by no signaling anything.

Without final, foo is virtual. The fact that C is static just means that it cannot read in the parent frame, e.g if declared inside a function body.

October 10, 2022

On Sunday, 9 October 2022 at 17:37:55 UTC, user1234 wrote:

>

On Sunday, 9 October 2022 at 16:05:32 UTC, Lucian Danescu wrote:

>

Hello!

[...]

Let's consider this code

static class C
{
    // ...
    final void foo() { ... }
    // ...
}

So in D-Scanner we have a check that warns against redundant usage of final keyword.
Final is indeed redundant with static methods, but with the current D-Scanner implementation,
in the example above the usage of final is not signaled, while with my implementation it is.

D-Scanner is right by no signaling anything.

Without final, foo is virtual. The fact that C is static just means that it cannot read in the parent frame, e.g if declared inside a function body.

Ah then I made a confusion here, I thought of a static class like in Java for example, meaning all methods inside that class are static as well. If I understood right, this is not the case?

October 10, 2022

On Monday, 10 October 2022 at 18:31:07 UTC, Lucian Danescu wrote:

>

Ah then I made a confusion here, I thought of a static class like in Java for example, meaning all methods inside that class are static as well. If I understood right, this is not the case?

That's a final class in D: https://dlang.org/spec/class.html#final

-Johan

October 11, 2022

On Monday, 10 October 2022 at 18:31:07 UTC, Lucian Danescu wrote:

>

On Sunday, 9 October 2022 at 17:37:55 UTC, user1234 wrote:

>

On Sunday, 9 October 2022 at 16:05:32 UTC, Lucian Danescu wrote:

>

Hello!

[...]

Let's consider this code

static class C
{
    // ...
    final void foo() { ... }
    // ...
}

So in D-Scanner we have a check that warns against redundant usage of final keyword.
Final is indeed redundant with static methods, but with the current D-Scanner implementation,
in the example above the usage of final is not signaled, while with my implementation it is.

D-Scanner is right by no signaling anything.

Without final, foo is virtual. The fact that C is static just means that it cannot read in the parent frame, e.g if declared inside a function body.

Ah then I made a confusion here, I thought of a static class like in Java for example, meaning all methods inside that class are static as well. If I understood right, this is not the case?

Yes but then that means you have a problem of attribute in the translation.
Possibly that comes from this deletion : https://github.com/Dlang-UPB/D-scanner/commit/054601076d02407988ae75941a8c9833a7768805#diff-e7443e5d080e9a77ae0fd18b6bd97f6df91fba93c8934bf965446463405e3ae7L88

The point here was exactly to avoid the false positive you have now.