Cannot check function address

Steven Schveighoffer schveiguy at gmail.com
Wed May 25 01:23:56 UTC 2022


On 5/24/22 6:10 PM, frame wrote:
> On Tuesday, 24 May 2022 at 19:09:52 UTC, Steven Schveighoffer wrote:
> 
>> This doesn't seem valid for module-level code, assert is an 
>> instruction, not a declaration.
>> ...
>> Try `std.traits.fullyQualifiedName!fun` to see where it's coming from.
>>
>> expected 5 got 0 suggests it is finding some other fun, as a.fun only 
>> takes a single parameter.
> 
> Of course this `assert()` is actually inside `static this()` and there 
> is only one declaration. I just want to show that the used symbol and 
> call is the same.

"of course" I have no idea what your real code looks like, unless you 
post the real code.

While I get the point of trying to slim down the example to something 
postable, a very common problem with this kind of self-trimming is that 
you end up trimming out the problematic code. Why? Because if you 
noticed the problematic code, you wouldn't be posting here, you would 
just fix it. This, in fact, happens to me frequently.

Now, it's also possible that there is an actual compiler bug here, it 
certainly seems like it could be, but a full (non-)working example would 
be useful.

I still highly recommend trying code like:

```d
import std.traits;
pragma(msg, fullyQualifiedName!fun);
```

inside the place where your assert is failing. To me, if it's using the 
expected symbol for `fun` (or whatever it's called), then it should 
print the definition you expect from the module you expect. If not, 
maybe there is a name conflict, and it's picking the wrong one? These 
problems can be tricky to find.

-Steve


More information about the Digitalmars-d-learn mailing list