[Issue 1424] New: is ( Type Identifier == function) Problems with inout/out/ref parameters
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 16 15:23:29 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1424
Summary: is ( Type Identifier == function) Problems with
inout/out/ref parameters
Product: D
Version: 1.020
Platform: PC
OS/Version: Windows
Status: NEW
Severity: critical
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: dbiehl at gmx.net
Hi,
I have some strange problems with IsExpression and inout/out/ref parameters,
first some code:
-------------- SNIP ---------------
//version = WithBar;
//version = BarWithParameterTypeTuple;
//version = DgWithParameterTypeTuple;
//version = WithAlsoFooParams;
import std.traits;
import std.stdio;
void foo(ref int i) {
}
static if (is(typeof(foo) P == function))
alias P FooParams;
else
static assert(0);
version(WithAlsoFooParams) {
static if (is(typeof(foo) P == function))
alias P AlsoFooParams;
else
static assert(0);
}
version(DgWithParameterTypeTuple) {
void function(ParameterTypeTuple!(foo)) dg;
} else {
void function(FooParams) dg;
}
version(WithBar) {
version(BarWithParameterTypeTuple) {
void bar(ParameterTypeTuple!(foo)) {
}
} else {
void bar(FooParams) {
}
}
}
int main(string[] args)
{
int i = 0;
writefln(typeof(&foo).stringof);
writefln(typeof(dg).stringof);
version(WithBar)
writefln(typeof(&bar).stringof);
return 0;
}
-------------- SNIP ---------------
I first define a function "foo", now I want to define a delegate "dg" with the
same parameters as foo. I get the parmeter tuple of foo with the isExpression.
The output of the code is:
void(*)((ref int))
void(*)((ref int))
how it should be. Now want to define a second function "bar" with the same
parameters as foo (Simple uncomment the first line "version = WithBar;"), I
thought the output is something like this, with a ref-Parameter:
void(*)((ref int))
void(*)((ref int))
void(*)((ref int))
but the output is:
void(*)((int _param_0))
void(*)((int _param_0))
void(*)((int _param_0))
where is the ref parameter in all lines?
Now get the parameter tuple of foo for function bar with the
std.traits.ParameterTypeTuple template. (uncomment the second line "version =
BarWithParameterTypeTuple;") The output is:
void(*)((ref int))
void(*)((ref int))
void(*)((int _param_0))
where is the ref in the last line?
until here everything compiles fine, but now I define a second alias of the
parameter tuples of foo (uncomment the 4. line "version = WithAlsoFooParams"
the and I get "Stack Overflow" from the DMD compiler and GDC hangs.
I try it with DMD versions 1.020, 2.003 and a SVN Trunk Version (Rev 139) of
GDC .
Greets Daniel
--
More information about the Digitalmars-d-bugs
mailing list