Issue 47: Strange Cpp-Compilation Error with enums and Type parameters
Status:  Fixed
Owner: ----
Closed:  Aug 2010
Reported by aboutwh...@googlemail.com, Aug 1, 2010
What steps will reproduce the problem?

try to compile the following code:

class TupleTools {
	
	public static inline function fst <T,S>(t:Tuple<T,S>):T
	{
		return switch (t) { case Tuple(a, b): a; };
	}
	
	public static inline function snd <T,S>(t:Tuple<T,S>):S
	{
		return switch (t) { case Tuple(a, b): b; };
	}
}


using Test.TupleTools;


enum Tuple<T,S> {
	Tuple(a:T, b:S);
}


class Test 
{
	public static function main() 
	{
		var t = Tuple(1, 2);
		trace(t.fst());
		trace(t.snd());
	}
}

this is the compilation output:

haxelib run hxcpp Build.xml haxe -Dcpp -Dhaxe_205 -Dtrue
cl.exe -Iinclude -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -Id:\work\dev\haxe\hxcpp/include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Ychxcpp.h __pch.cpp /Fphxcpp.pch
__pch.cpp
cl.exe -I. -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -Id:\work\dev\haxe\hxcpp/include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Iinclude -Yuhxcpp.h ./src/Test.cpp -Foobj/Release/src/Test.obj
cl.exe -I. -nologo -O2 -MT -DHX_WINDOWS -GR -Zi -c -EHsc -Id:\work\dev\haxe\hxcpp/include -D_CRT_SECURE_NO_DEPRECATE -wd4996 -Iinclude -Yuhxcpp.h ./src/Tuple.cpp -Foobj/Release/src/Tuple.obj
Test.cpp
Tuple.cpp
./src/Test.cpp(10) : fatal error C1083: Cannot open include file: 'fst/S.h': No such file or directory
Called from <null> line 1
Called from BuildTool.hx line 883
Called from BuildTool.hx line 451
Called from BuildTool.hx line 474
Called from BuildTool.hx line 547
Called from BuildTool.hx line 618
Uncaught exception - Error in building thread
Error : Build failed



Aug 1, 2010
Project Member #1 gameh...@gmail.com
Slightly simplified code - it is the "inline" that is causing the problem. The resultant code refers to "used.UsedPrivate" from "main", which I think is  a problem with the inlining code.

class Usable {
   public static inline function used<UsedPrivate>( val:Templ<UsedPrivate> ) : UsedPrivate
   {
      return switch(val) { case Val(a): a; }
   }
}

enum Templ<T>
{
  Val(a:T);
}

using Test.Usable;

class Test
{
   public static function main()
   {
      var t = Val(1);
      trace( t.used() );
   }
}

Aug 9, 2010
Project Member #2 gameh...@gmail.com
Fixed on haxe svn
Status: Fixed