[Issue 10936] New: unittest in struct body makes crash dmd

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Aug 31 11:31:53 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10936

           Summary: unittest in struct body makes crash dmd
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: code.viator at gmail.com


--- Comment #0 from Oleg B <code.viator at gmail.com> 2013-08-31 11:31:52 PDT ---
[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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list