www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10936] New: unittest in struct body makes crash dmd

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: code.viator gmail.com


--- Comment #0 from Oleg B <code.viator 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: -------
Aug 31 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10936



--- Comment #1 from Oleg B <code.viator gmail.com> 2013-08-31 11:33:54 PDT ---
I want say UNCOMMENT 11,12 lines

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 31 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10936


Henning Pohl <henning still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |henning still-hidden.de


--- Comment #2 from Henning Pohl <henning still-hidden.de> 2013-09-01 05:25:27
PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 01 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10936



--- Comment #3 from Henning Pohl <henning still-hidden.de> 2013-09-01 05:45:36
PDT ---
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;
---

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