www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4516] New: forward declaration of enum not supported

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

           Summary: forward declaration of enum not supported
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: braddr puremagic.com


--- Comment #0 from Brad Roberts <braddr puremagic.com> 2010-07-27 00:21:19 PDT
---
module foo;

struct A { B b; }
enum B { Z }

$ dmd -c foo.d
foo.d(3): Error: enum B is forward referenced

(flagging as D2 only since I haven't tested with D1 -- quite possibly broken
with both)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Leandro Lucarella <llucax gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |llucax gmail.com


--- Comment #1 from Leandro Lucarella <llucax gmail.com> 2010-07-27 06:42:08
PDT ---
(In reply to comment #0)
 (flagging as D2 only since I haven't tested with D1 -- quite possibly broken
 with both)
Nope, D2-only (at least svn r584 works). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug yahoo.com.au


--- Comment #2 from Don <clugdbug yahoo.com.au> 2010-07-27 07:31:12 PDT ---
(In reply to comment #1)
 (In reply to comment #0)
 (flagging as D2 only since I haven't tested with D1 -- quite possibly broken
 with both)
Nope, D2-only (at least svn r584 works).
It failed up to D1.053. It works in D1.054 and later. Interestingly it also worked in D2.038 and 2.039 ONLY (released with 1.054), it had failed in 2.037 and earlier, but failed again starting with 2.040. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
             Blocks|                            |340
           Severity|normal                      |regression


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 27 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516



--- Comment #3 from Sobirari Muhomori <dfj1esp02 sneakemail.com> 2010-07-28
11:41:50 PDT ---
See bug 1160

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 28 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4516


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
            Summary|forward declaration of enum |Regression(2.040): forward
                   |not supported               |declaration of enum not
                   |                            |supported


--- Comment #4 from Don <clugdbug yahoo.com.au> 2010-08-06 02:23:31 PDT ---
The fix to bug 1160 was what originally fixed it (in toBasetype(), do full
semantic on the enum type when forward referenced); the fix to bug 3723 broke
it again (in toBasetype(), only do semantic on the type, not on the full enum).
In this situation, it does actually does the need the full semantic to be run.

Although this test case passes in D1, I'm not convinced that D1 is correct (it
doesn't check for forward references at all).
----
PATCH: mtype.c, line 6340.

int TypeEnum::isZeroInit(Loc loc)
{
+    if (!sym->defaultval && sym->scope)
+    {   // Enum is forward referenced. We need to resolve the whole thing.
+        sym->semantic(NULL);
+    }
    if (!sym->defaultval)
    {
#ifdef DEBUG
        printf("3: ");
#endif
        error(loc, "enum %s is forward referenced", sym->toChars());
        return 0;
    }
    return sym->defaultval->isBool(FALSE);
}

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


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com
            Version|D2                          |D1


--- Comment #5 from Walter Bright <bugzilla digitalmars.com> 2010-08-08
20:51:50 PDT ---
You're right that D1 doesn't check for it, as defaultVal is just an integer.
I'll apply your fix for D2, but leave the bug open for D1.

http://www.dsource.org/projects/dmd/changeset/605

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


Don <clugdbug yahoo.com.au> changed:

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


--- Comment #6 from Don <clugdbug yahoo.com.au> 2010-08-29 23:59:47 PDT ---
I have moved the D1 version of this bug into the newly created bug 4768. Both
symptoms and solution are different for D1.

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


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|D1                          |D2


--- Comment #7 from Stewart Gordon <smjg iname.com> 2010-08-30 04:44:46 PDT ---
But you left this one filed as a D1 bug.

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