Cannot check function address

user1234 user1234 at 12.de
Wed May 25 10:55:02 UTC 2022


On Wednesday, 25 May 2022 at 06:04:10 UTC, frame wrote:
> On Wednesday, 25 May 2022 at 05:56:28 UTC, Steven Schveighoffer 
> wrote:
>
>> It's a case where the compiler can't divine what you were 
>> thinking when you wrote that code ;)
>
> I see not in all cases but in mine. If the compiler sees the 
> function isn't callable without arguments and it is inside an 
> if-statement or `assert()` then it could at least suggest a 
> pointer or ask: are you dumb? ;-)

As suggested by others, the reduction is not correct, you have 
stripped too muchbecause this compiles just fine:

a.d:
```d
alias F = void function(int);
F f;

static this()
{
     assert(!f);
     assert(f is null);
}
```

b.d:
```d
import a;

static this()
{
     assert(!f);
     assert(f is null);
}
```

```sh
$ dmd a.d b.d -main
$ echo $?
$ 0
```


More information about the Digitalmars-d-learn mailing list