Bug 10936 – unittest in struct body makes crash dmd
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-31T11:31:00Z
Last change time
2013-11-21T22:19:34Z
Assigned to
nobody
Creator
code.viator
Comments
Comment #0 by code.viator — 2013-08-31T11:31:52Z
[code]
struct vec( size_t N, string AS="" )
{
float[N] data;
this(E)( E[] ext... ) { data[0] = 0; }
@property auto opDispatch(string v)() const
{ mixin( "return vec!(v.length,v)( 0 );" ); }
unittest {
auto pos = vec!(3,"xyz")( 1, 2, 10 );
//auto pxx = pos.xy;
//assert( is( typeof( pxy ) == vec!(2,"xy") ) );
assert( is( typeof( pos.xy ) == vec!(2,"xy") ) );
}
}
unittest { vec!(3,"xyz") a; }
[/code]
if unittest in struct body I have error:
dmd: func.c:1299: virtual void FuncDeclaration::semantic3(Scope*): Assertion `type == f' failed.
if uncomment 11,12 lines and comment I have error:
dmd: struct.c:741: virtual void StructDeclaration::semantic(Scope*): Assertion `type->ty != Tstruct || ((TypeStruct *)type)->sym == this' failed.
if unittest take away from a body I haven't dmd errors
[code]
struct vec( size_t N, string AS="" )
{
float[N] data;
this(E)( E[] ext... ) { data[0] = 0; }
@property auto opDispatch(string v)() const
{ mixin( "return vec!(v.length,v)( 0 );" ); }
}
unittest { vec!(3,"xyz") a; }
unittest {
auto pos = vec!(3,"xyz")( 1, 2, 10 );
auto pxx = pos.xy;
assert( is( typeof( pxy ) == vec!(2,"xy") ) );
assert( is( typeof( pos.xy ) == vec!(2,"xy") ) );
}
[/code]
i use:
$ dmd -unittest -main file.d
system:
$ uname -a
Linux lenovo 3.9.11-200.fc18.x86_64 #1 SMP Mon Jul 22 21:04:50 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
DMD64 D Compiler v2.063.2
Comment #1 by code.viator — 2013-08-31T11:33:54Z
I want say UNCOMMENT 11,12 lines
Comment #2 by henning — 2013-09-01T05:25:27Z
Reduced:
----
struct Vec(string s)
{
auto opDispatch(string v)()
{
return Vec!v.init;
}
void foo()
{
auto v = Vec!"".init;
auto p = v.something;
}
}
Vec!"" v;
----
Replace Vec!v.init with Vec!v() to second assertion instead.
Comment #3 by henning — 2013-09-01T05:45:36Z
This shows the errors which have been gagged:
---
struct Vec(string s)
{
auto foo(string v)()
{
return Vec!(v)();
}
static void bar()
{
Vec!"" v;
auto p = v.foo!"sup";
}
}
Vec!"" v;
---
Comment #4 by k.hara.pg — 2013-11-21T19:59:03Z
The ICE will be fixed by fixing issue 10938.
Comment #5 by k.hara.pg — 2013-11-21T22:19:34Z
Forward reference issue is a dup of issue 9050.
*** This issue has been marked as a duplicate of issue 9050 ***