Thread overview
[Issue 2694] New: alias pure nothrow XXX; is not pure nothrow!
Feb 27, 2009
d-bugmail
Oct 27, 2009
Don
Oct 29, 2009
Leandro Lucarella
Nov 06, 2009
Walter Bright
February 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2694

           Summary: alias pure nothrow XXX; is not pure nothrow!
           Product: D
           Version: 2.025
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: clugdbug@yahoo.com.au


But alias XXX pure nothrow; works!
----
pure nothrow {
  alias void function(int) A;   // A is pure nothrow
}

alias void function(int) pure nothrow  B; // B is pure nothrow
alias pure nothrow void function(int) C; // C is NOT pure nothrow!

void main()
{
    A a = null;
    B b = null;
    C c = null;
    a = b; // ok
    a = c; // fails!
}
---
bug.d(15): Error: cannot implicitly convert expression (c) of type void
function
(int) to void function(int) pure nothrow
---
If you take away the aliases, and use variables A, B, C instead, it works. So it's a problem with 'alias'.


-- 

October 27, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2694


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, wrong-code


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2009-10-27 12:21:31 PDT ---
// PATCH: pure, nothrow need the same treatment which ref already has.

Index: declaration.c ===================================================================
--- declaration.c    (revision 221)
+++ declaration.c    (working copy)
@@ -461,11 +461,11 @@
     goto L2;            // it's a symbolic alias

 #if DMDV2
-    if (storage_class & STCref)
+    if (storage_class & (STCref | STCnothrow | STCpure))
     {    // For 'ref' to be attached to function types, and picked
     // up by Type::resolve(), it has to go into sc.
     sc = sc->push();
-    sc->stc |= STCref;
+    sc->stc |= (storage_class & (STCref | STCnothrow |STCpure));
     type->resolve(loc, sc, &e, &t, &s);
     sc = sc->pop();
     }

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


Leandro Lucarella <llucax@gmail.com> changed:

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


--- Comment #2 from Leandro Lucarella <llucax@gmail.com> 2009-10-29 14:39:03 PDT ---
Related SVN revision: http://www.dsource.org/projects/dmd/changeset/225

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


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2009-11-06 11:32:57 PST ---
Fixed dmd 2.036

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