www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1170] New: Cannot forward reference a type defined in a MixinStatement

reply d-bugmail puremagic.com writes:
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.


-- 
Apr 20 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170




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: -------
Sep 23 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



PDT ---
patch is against 2.032

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 23 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Walter Bright <bugzilla digitalmars.com> changed:

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



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: -------
Sep 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170




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: -------
Sep 29 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170




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: -------
Oct 13 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
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



15:04:26 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.
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: -------
Oct 13 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Jerry Quinn <jlquinn optonline.net> changed:

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



---
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: -------
Feb 23 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Feb 08 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1170


Don <clugdbug yahoo.com.au> changed:

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



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: -------
Feb 09 2011