D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 390 - Cannot forward reference enum nested in struct
Summary: Cannot forward reference enum nested in struct
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid
Depends on: 1160
Blocks: 340
  Show dependency treegraph
 
Reported: 2006-09-29 19:40 UTC by Bradley Smith
Modified: 2014-02-15 13:21 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Bradley Smith 2006-09-29 19:40:27 UTC
$ dmd testStructEnum.d
testStructEnum.d(6): no property 'Id' for type 'Value'
testStructEnum.d(6): Value.Id is used as a type
testStructEnum.d(6): cannot have parameter of type void

$ dmd testStructEnum.d -version=works
gcc testStructEnum.o -o testStructEnum -m32 -lphobos -lpthread -lm -Xlinker -L/home/bsmith/tools/d/dmd/lib
$ ./testStructEnum
1



----- testStructEnum.d -----
import std.stdio;

version(works) {
} else { // Doesn't work

  void f(Value.Id t) {
    writefln(cast(int)t);
  }

}

struct Value {
  public static enum Id {
    A,
    B
  }
}

version(works) {

  void f(Value.Id t) {
    writefln(cast(int)t);
  }

}

void main() {
  Value.Id t = Value.Id.B;
  f(t);
}
----------
Comment 1 Bradley Smith 2006-09-30 00:06:51 UTC
Fails on Windows XP also.
Comment 2 Stewart Gordon 2006-11-16 18:39:55 UTC
It also fails with a struct nested within a struct.  Probably part of the same bug.  IIRC class within struct, struct within class and class within class all fail.

----------
struct Qwert {
    Yuiop.Asdfg hjkl;
}

struct Yuiop {
    struct Asdfg {
        int zxcvb;
    }
}
----------
Comment 3 Rainer Schuetze 2009-09-18 01:00:45 UTC
The patch in issue 282 also fixes this issue.
Comment 4 Walter Bright 2009-12-31 11:09:39 UTC
Fixed dmd 1.054 and 2.038