D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2694 - alias pure nothrow XXX; is not pure nothrow!
Summary: alias pure nothrow XXX; is not pure nothrow!
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch, rejects-valid, wrong-code
Depends on:
Blocks:
 
Reported: 2009-02-27 09:09 UTC by Don
Modified: 2015-06-09 01:21 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Don 2009-02-27 09:09:43 UTC
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'.
Comment 1 Don 2009-10-27 12:21:31 UTC
// 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();
     }
Comment 2 Leandro Lucarella 2009-10-29 14:39:03 UTC
Related SVN revision: http://www.dsource.org/projects/dmd/changeset/225
Comment 3 Walter Bright 2009-11-06 11:32:57 UTC
Fixed dmd 2.036