Thread overview
[Issue 3723] New: Regression: forward referenced enum
Jan 19, 2010
Don
Jan 20, 2010
Don
Jan 20, 2010
Don
Jan 24, 2010
Walter Bright
Jan 31, 2010
Walter Bright
January 19, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3723

           Summary: Regression: forward referenced enum
           Product: D
           Version: 1.054
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2010-01-19 08:44:58 PST ---
This code worked on 1.053, fails to compile on 1.054, and on D2. I suspect this was caused by the fix to bug 3611.
-----
FwdEnum this_fails;

enum :int
{
        E1 =  2
}

enum FwdEnum: int
{
        E2 =  E1
}
-----
bug.d(10): Error: undefined identifier E1

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



--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-01-19 21:43:23 PST ---
The regression is caused by this addition to Type *TypeEnum::toBasetype(). Knowing this doesn't necessarily help in fixing the problem, though.

Type *TypeEnum::toBasetype()
{
+    if (sym->scope)
+    {
+    sym->semantic(NULL);    // attempt to resolve forward reference
+    }

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


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-01-20 11:31:37 PST ---
I've fixed this by changing the code in mtype.c, line 5984:

Type *TypeEnum::toBasetype()
{
    if (sym->scope)
    {
-    sym->semantic(NULL);    // attempt to resolve forward reference
+    sym->trySemantic(NULL);    // attempt to resolve forward reference
    }

and adding this code to enum.c:

void EnumDeclaration::trySemantic(Scope *sc)
{
    unsigned errors = global.errors;
    global.gag++;
    DsymbolTable *savetable = symtab;
    semantic(sc);
    global.gag--;
    if (errors != global.errors)
    {
    global.errors = errors;
    symtab = savetable;
    }
}

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2010-01-24 15:02:43 PST ---
Changeset 353

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2010-01-30 22:42:12 PST ---
fixed dmd 1.056 and 2.040

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