[Issue 2687] New: ICE in statement.c: ParameterTypeTuple of aliased function and friends
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Feb 24 06:39:38 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2687
Summary: ICE in statement.c: ParameterTypeTuple of aliased
function and friends
Product: D
Version: 2.025
Platform: PC
OS/Version: Windows
Status: NEW
Keywords: ice-on-valid-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: daniel.keep+d.puremagic.com at gmail.com
There appears to be a few problems here, so I'll try to summarise as best I
can.
I have two modules fnalias and fnalias_reflect. There is a class in
fnalias_reflect with a template member "void expose(alias Fn)(in string name)".
This member directly instantiates a private template in fnalias_reflect
"extern(C) int WrapLuaFunction(alias Fn)()".
Inside the WLF template function, I derive the type of the arguments of the
function using std.traits.ParameterTypeTuple, then foreach over an instance of
the resulting type tuple and static assert(isValidArgType!(typeof(x))) each
member.
Now, this works fine in the case of zero arguments. For a non-zero number of
arguments, however, the compiler aborts on the static assert with the
following:
Statement::blockExit(02D82CCC)
static assert(isValidArgType!(argT));
Assertion failure: '0' on line 123 in file 'statement.c'
abnormal program termination
Here's where it gets really weird. If I add this line at the top of the
template:
pragma(msg, "Fn: " ~ Fn.stringof);
Then ParameterTypeTuple derives the argument types as "int" when it should be
"(double, double)".
But wait, there's more. If I change the template's signature to this:
extern(C) int WrapNativeFunction(alias Fn)(lua_State* L)
then the compiler fails on the case of a function with zero arguments,
mistakenly deriving the argument types of "void hello()" as being "int". Note
that lua_State is undefined.
I will attach these source files, which represent as minimal a test case as I
could make. When the two files are compiled together with a stock 2.025
compiler (no command-line arguments other than fnalias.d and fnalias_reflect.d)
it aborts at fnalias_reflect.d:51. You should also try compiling after
uncommenting fnalias_reflect.d:34 (the pragma variant) and by uncommenting the
argument to the template function on line 30.
--
More information about the Digitalmars-d-bugs
mailing list