You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//----
class A{}
auto a = new A; //(3)
immutable ia = new immutable(A); //(4)
auto i = new int; //(5)
immutable ii = new immutable(int); //(6)
struct S
{
auto a = new A; //(10) HERE!!!
auto i = new int; //(11)
}
//----
I'm not sure if this is a reg, but:
2.062:
main.d(3): Error: cannot evaluate new A at compile time
main.d(4): Error: cannot evaluate new immutable(A) at compile time
main.d(5): Error: cannot evaluate new int at compile time
main.d(6): Error: cannot evaluate new immutable(int) at compile time
main.d(10): Error: cannot evaluate new A at compile time
main.d(11): Error: cannot evaluate new int at compile time
2.063 has allowed evaluating classes at compile time (but not ints, apparently):
main.d(3): Error: variable main.a is mutable. Only const or immutable class thread local variable are allowed, not main.A
main.d(5): Error: Cannot interpret new int at compile time
main.d(6): Error: Cannot interpret new immutable(int) at compile time
main.d(11): Error: Cannot interpret new int at compile time
I believe that this code is wrong:
- first, because it is surprising that 'a' reference a global class instance, as opposed to a new A for each new S (even if it's the correct behavior).
- second, because the new global instance is not TLS (referenced by T.init), yet is placed in a non-shared.
Line 10 should be illegal. It should be either of:
immutable ai = new immutable(A);
shared as = new shared(A);
The text was updated successfully, but these errors were encountered:
monarchdodra reported this on 2013-09-22T23:57:30Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=11107
CC List
Description
//---- class A{} auto a = new A; //(3) immutable ia = new immutable(A); //(4) auto i = new int; //(5) immutable ii = new immutable(int); //(6) struct S { auto a = new A; //(10) HERE!!! auto i = new int; //(11) } //---- I'm not sure if this is a reg, but: 2.062: main.d(3): Error: cannot evaluate new A at compile time main.d(4): Error: cannot evaluate new immutable(A) at compile time main.d(5): Error: cannot evaluate new int at compile time main.d(6): Error: cannot evaluate new immutable(int) at compile time main.d(10): Error: cannot evaluate new A at compile time main.d(11): Error: cannot evaluate new int at compile time 2.063 has allowed evaluating classes at compile time (but not ints, apparently): main.d(3): Error: variable main.a is mutable. Only const or immutable class thread local variable are allowed, not main.A main.d(5): Error: Cannot interpret new int at compile time main.d(6): Error: Cannot interpret new immutable(int) at compile time main.d(11): Error: Cannot interpret new int at compile time I believe that this code is wrong: - first, because it is surprising that 'a' reference a global class instance, as opposed to a new A for each new S (even if it's the correct behavior). - second, because the new global instance is not TLS (referenced by T.init), yet is placed in a non-shared. Line 10 should be illegal. It should be either of: immutable ai = new immutable(A); shared as = new shared(A);The text was updated successfully, but these errors were encountered: