www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Some template code that worked in 2.065 is not working in 2.066

reply "Uranuz" <neuranuz gmail.com> writes:
In my project I have sort of complicated logic to implement data 
structure that is somehow similar to std.typecons.Tuple. I can't 
reproduce it, because I can't locate the source of bug. My code 
is like this but have more nested template "calls".

import std.stdio, std.typetuple;

struct MyLib(Args...)
{
	alias Symbols = _parseArgs!Args;
	
	template GetNames()
	{
		alias GetNames = Symbols;
	}
}


template _parseArgs(Args...)
{
	alias _parseArgs = TypeTuple!Args;
}

void main()
{
	auto myLib = MyLib!("a", "b", "c")();
	
	foreach( item; myLib.GetNames!() ) //Error: expression has no 
value
		writeln(item);

	//foreach( item; typeof(myLib).GetNames!() ) //This is working
	//	writeln(item);
}

Swapping lines that marked as error with commented lines makes it 
working. In this example error happens using 2.065 and 2.066, but 
in *my project*, where code is similar to this it compiles in 
2.065 but fails in 2.066.

So what should be working in this example by language spec?
1. myLib.GetNames!()
2. typeof(myLib).GetNames!()
3. Both of the above

And it's interesting to see any reasons why this happens.
Aug 22 2014
next sibling parent "Dicebot" <public dicebot.lv> writes:
I believe it should work (it is no different from foreach(elem; 
myLib.Symbols) which works), but there are better experts on such 
topics hanging around.
Aug 22 2014
prev sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Friday, 22 August 2014 at 08:47:23 UTC, Uranuz wrote:
 In my project I have sort of complicated logic to implement 
 data structure that is somehow similar to std.typecons.Tuple. I 
 can't reproduce it, because I can't locate the source of bug.
You could try using DustMite: https://github.com/CyberShadow/DustMite You can try to reduce the program to a smallest one that compiles in one version, but doesn't in another: https://github.com/CyberShadow/DustMite/wiki/Reducing-a-regression-between-two-D-versions You could also use Digger to find the compiler change which caused your code to stop compiling: https://github.com/CyberShadow/Digger
Aug 22 2014
parent "Uranuz" <neuranuz gmail.com> writes:
On Friday, 22 August 2014 at 17:08:39 UTC, Vladimir Panteleev 
wrote:
 On Friday, 22 August 2014 at 08:47:23 UTC, Uranuz wrote:
 In my project I have sort of complicated logic to implement 
 data structure that is somehow similar to std.typecons.Tuple. 
 I can't reproduce it, because I can't locate the source of bug.
You could try using DustMite: https://github.com/CyberShadow/DustMite You can try to reduce the program to a smallest one that compiles in one version, but doesn't in another: https://github.com/CyberShadow/DustMite/wiki/Reducing-a-regression-between-two-D-versions You could also use Digger to find the compiler change which caused your code to stop compiling: https://github.com/CyberShadow/Digger
Thanks. I have no experience with these instrumnets yet. For now I just changed mu code for using *typeof*. I'll try to locate the source of problem when I have some time.
Aug 23 2014