Thread overview
[Issue 7249] New: 2.058 regression: "no size yet for forward reference" when using this.init.tupleof
Jan 08, 2012
Vladimir Panteleev
Jan 08, 2012
Kenji Hara
Jan 08, 2012
Vladimir Panteleev
Jan 08, 2012
Vladimir Panteleev
Jan 08, 2012
Kenji Hara
Jan 08, 2012
Vladimir Panteleev
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7249

           Summary: 2.058 regression: "no size yet for forward reference"
                    when using this.init.tupleof
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: thecybershadow@gmail.com


--- Comment #0 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-01-08 10:09:34 PST ---
struct S
{
    int x;
    alias typeof(this.init.tupleof[0]) T;
}

This worked in 2.057, but doesn't work in DMD git head.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7249



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-08 15:05:22 PST ---
This causes by fixing bug 7190.

I think this is similar problem like follows:

struct S
{
    int x;
    alias typeof(this.init.sizeof) T;
    //  Error: struct test.S no size yet for forward reference
}

tupleof property requires complete semantic analysis to get the fields of a
type.
So it is meaningful forward reference, IMHO.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7249



--- Comment #2 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-01-08 15:11:53 PST ---
In my case, the list of fields is passed as a template parameter:

struct S(string FIELDS)
{
    mixin(FIELDS);

    alias typeof(Fields.init.tupleof[0]) TypeOfFirstField;
}

There is a simple workaround available:

    struct Fields { mixin(FIELDS); }
    alias typeof(Fields.init.tupleof[0]) TypeOfFirstField;

So, if you think this is not a bug, I'm not against this change.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7249



--- Comment #3 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-01-08 15:15:23 PST ---
(In reply to comment #2)
> In my case, the list of fields is passed as a template parameter:
> 
> struct S(string FIELDS)
> {
>     mixin(FIELDS);
> 
>     alias typeof(Fields.init.tupleof[0]) TypeOfFirstField;

Oops, last line should be:
      alias typeof(this.init.tupleof[0]) TypeOfFirstField;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7249



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-08 15:25:00 PST ---
(In reply to comment #2)
> So, if you think this is not a bug, I'm not against this change.

Yes, I think this is not a bug.

Additionally, old behavior had a order dependent problem.

struct S
{
    alias typeof(this.init.tupleof[0]) T;
    // Error: array index [0] is outside array bounds [0 .. 0]
    // -> tupleof result was empty

    int x;

    alias typeof(this.init.tupleof[0]) T;
    // OK, T == int
}

Now they raise forward reference error as a same.
I think it's better consistency.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 08, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7249


Vladimir Panteleev <thecybershadow@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #5 from Vladimir Panteleev <thecybershadow@gmail.com> 2012-01-08 15:26:02 PST ---
OK, thanks for looking into this.

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