visuald icon indicating copy to clipboard operation
visuald copied to clipboard

Goto definition not reliable

Open TurkeyMan opened this issue 6 months ago • 6 comments

Hey there, just trying out your new build. Other recent issues appear to be fixed. Today I wanted to try and get to the bottom of some of these issues with goto definition not working reliably.

The first sample case I bumped into looks like this:

char[] tconcat(Args...)(ref Args args)
{
	import urt.string.format : concat;
	char[] r = concat(cast(char[])tempMem[allocOffset..$], args);
	if (!r)
	{
		allocOffset = 0;
		r = concat(cast(char[])tempMem[0..TempMemSize / 2], args);
	}
	allocOffset += r.length;
	return r;
}

You can see the import urt.string.format : concat; there, and 2 calls to concat inside this function. If I cursor over concat and goto definition, it doesn't go anywhere. I figure the first thing to do is check the log for an error explanation, but it didn't say anything:

19:25:19 - ba64 -   schedule GetDefinition: D:\Code\monitor\src\urt\mem\temp.d
19:25:19 - ba64 - GetDefinitionResult: 
19:25:20 - ba64 -   schedule GetDefinition: D:\Code\monitor\src\urt\mem\temp.d
19:25:20 - ba64 - GetDefinitionResult: 
19:25:21 - ba64 -   schedule GetDefinition: D:\Code\monitor\src\urt\mem\temp.d
19:25:21 - ba64 - GetDefinitionResult: 
19:25:21 - ba64 -   schedule GetDefinition: D:\Code\monitor\src\urt\mem\temp.d
19:25:21 - ba64 - GetDefinitionResult: 

What's my next port of call to try and track this down?

I did wonder; given a template function without an instantiation like this, how does the frontend even perform semantic to determine what these local symbols are? Can DMD begin to meaningfully compile this code without knowing what Args is?

TurkeyMan avatar May 02 '25 09:05 TurkeyMan