[Issue 5110] Excess attribute propagation of structs and classes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 24 02:12:58 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5110
--- Comment #2 from Shin Fujishiro <rsinfu at gmail.com> 2010-10-24 02:09:16 PDT ---
Created an attachment (id=792)
Testcases
Since nothrow, pure and @disable are one-way, non-revertible attributes, the
language should not force them to be propagated IMO. So, structs and classes
should really propagate only the following STCs:
STCimmutable, STCconst, STCshared, STCsynchronized,
STCsafe, STCtrusted, STCsystem.
Note that the first four STCs must not be applied to static members, including
nested types:
--------------------
const synchronized class C
{
static int value; // NO const
enum E { a, b, c } // NO const
class N {} // NO const synchronized
}
--------------------
The nested class N itself isn't necessarily const nor synchronized, since its
declaration is effectively the same as the following one. Whether N should be
const/synchronized or not is independent of C.
--------------------
class N
{
C outer; // C is already const synchronized
}
--------------------
To sum up, the rule allows these attribute propagations:
- const, shared, immutable and synchronized over non-static members
- @safe, @trusted and @system over all members
Attached test cases.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list