Thread overview
[Issue 1170] New: Cannot forward reference a type defined in a MixinStatement
Apr 20, 2007
d-bugmail
Sep 23, 2009
Rainer Schuetze
Sep 23, 2009
Rainer Schuetze
Sep 29, 2009
Walter Bright
Sep 30, 2009
Rainer Schuetze
Oct 13, 2009
Rainer Schuetze
Oct 13, 2009
Eldar Insafutdinov
Feb 23, 2010
Jerry Quinn
Feb 08, 2011
Don
Feb 09, 2011
Don
April 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1170

           Summary: Cannot forward reference a type defined in a
                    MixinStatement
           Product: D
           Version: 1.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: deewiant@gmail.com
OtherBugsDependingO 340
             nThis:


(Set version to 1.012, as 1.013 isn't in the list yet.)

type x;
mixin("alias int type;");

All of alias, typedef, enum, struct, class, and a template containing any of the above don't work.

Flip the order of the two lines or replace the mixin with its contents and the code compiles.


-- 

September 23, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1170



--- Comment #1 from Rainer Schuetze <r.sagitario@gmx.de> 2009-09-23 13:55:32 PDT ---
Created an attachment (id=464)
invalidate symbol search cache when adding new symbol

the problem in the test case consists of 2 issues.
1. the forward referencing of the type. this is fixed by the patch in issue 102
2. the new symbol not being found in the symbol table. This can be reproduced
without triggering bug 102 by

static if(is(type)) {}
mixin("alias int type;");
type x;

test.d(3): Error: identifier 'type' is not defined

The problem is that the last symbol being searched in a module is cached to speed up consecutive lookups of the same symbol. When a symbol is added by the mixin, this cached result is not invalidated. The patch adds this invalidation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 23, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Rainer Schuetze <r.sagitario@gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |r.sagitario@gmx.de


--- Comment #2 from Rainer Schuetze <r.sagitario@gmx.de> 2009-09-23 13:56:41 PDT ---
patch is against 2.032

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2009-09-29 15:09:39 PDT ---
The patch doesn't work, even when I disable the cache completely. The reason it doesn't work is because mixins are evaluated at a later stage in the compilation process.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 30, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1170



--- Comment #4 from Rainer Schuetze <r.sagitario@gmx.de> 2009-09-29 23:51:07 PDT ---
The patch only fixes the name lookup, not the forward reference. As described in comment 1, you'll also need the patch from issue 102 to completely fix the original test case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1170



--- Comment #5 from Rainer Schuetze <r.sagitario@gmx.de> 2009-10-13 01:41:54 PDT ---
As it seems, a patch has crawled into DMD 2.033 that is supposed to fix the second issue described in comment 1. This is line 887 in module.c (in dmd 2.034)

else if (searchCacheIdent == ident && searchCacheFlags == flags &&
searchCacheSymbol)

where searchCacheSymbol has been added to allow finding symbols that have been added after the last search.

Though this fixes the issue, it has a bad impact on identifier lookup time, especially with a lot of imports, worst with cyclic imports. This is because with this change, not finding an identifier is always expensive, but it is the most common result.

This has now shown up with qtd causing the build to lock-up with continuously searching identifiers.  I'd still suggest a change along the lines of the patch posted in this issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 13, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Eldar Insafutdinov <e.insafutdinov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |e.insafutdinov@gmail.com


--- Comment #6 from Eldar Insafutdinov <e.insafutdinov@gmail.com> 2009-10-13 15:04:26 PDT ---
(In reply to comment #5)
> As it seems, a patch has crawled into DMD 2.033 that is supposed to fix the second issue described in comment 1. This is line 887 in module.c (in dmd 2.034)
> 
> else if (searchCacheIdent == ident && searchCacheFlags == flags &&
> searchCacheSymbol)
> 
> where searchCacheSymbol has been added to allow finding symbols that have been added after the last search.
> 
> Though this fixes the issue, it has a bad impact on identifier lookup time, especially with a lot of imports, worst with cyclic imports. This is because with this change, not finding an identifier is always expensive, but it is the most common result.
> 
> This has now shown up with qtd causing the build to lock-up with continuously searching identifiers.  I'd still suggest a change along the lines of the patch posted in this issue.

The applied patch in rev. 205 brought QtD back to life.

Thank you.

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


Jerry Quinn <jlquinn@optonline.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlquinn@optonline.net


--- Comment #7 from Jerry Quinn <jlquinn@optonline.net> 2010-02-23 05:37:47 PST ---
A related example that fails to compile:

enum Y { A, B=mixin(s), C }
const string s="4";

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


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

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


--- Comment #8 from Don <clugdbug@yahoo.com.au> 2011-02-08 04:37:34 PST ---
The test case in comment 7 was fixed in 2.051 and 1.066. The original test case still doesn't work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=1170


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

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


--- Comment #9 from Don <clugdbug@yahoo.com.au> 2011-02-09 02:53:22 PST ---
I'm removing the 'patch' keyword, since even though the patches from here and from bug 102 have been applied, the original bug is not fixed.

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