www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12496] New: __traits(parent, x) returns incorrect type

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12496

           Summary: __traits(parent, x) returns incorrect type
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: slavo5150 yahoo.com



Consider the following code:

/*********** mmio.d ************/
module mmio;

mixin template HasValue(uint value) {
    static uint getValue() {
        return value;
    }
}

mixin template Parent() {
    final abstract class Child(uint value) {
        mixin HasValue!(value);
    }
}

/*********** test.d ************/
module test;
import mmio;

mixin Parent;

alias Two = Child!(2);

/*********** main.d ************/
import std.stdio;
import test;

void main()
{
    writeln(__traits(parent, test.Two).stringof);
    writeln(__traits(parent, __traits(parent, 
test.Two)).stringof);

    readln();
}

DMD 2.065 Output:
Child!(2)
Child!(2)

GDC 4.8.2 20130725 Output:
Child
Child

LDC 0.12.1 Output:
Child
Child

Expected output:
module test
{the second `writeln` shouldn't compile since `test` has no parent}

A couple of observations:
1. `Child` is not the parent of `test.Two`, `test` is the parent of `test.Two`.
2. If you believe `__traits(parent, test.Two)` is `Child`, `Child` should not
be its own parent.

If the template parameter on `Child` is removed, it returns the correct type.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 30 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12496


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



14:08:20 CEST ---
Seems similar to a bug Vladimir filed recently.

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