[Issue 9040] Assertion `precedence[e->op] != PREC_zero' failed instantiating anonymous class at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 22 05:15:38 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=9040



--- Comment #10 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-11-22 05:15:35 PST ---
(In reply to comment #9)
> (In reply to comment #8)
> > (In reply to comment #7)
> > > test.d(5): Error: variable test.main.staticAnonInstance is mutable. Only const
> > > or immutable class thread local variable are allowed, not test.BaseClass
> > 
> > Btw, can we do something about this diagnostic? It makes absolutely no sense at
> > all. Here's a mutable class thread-local variable:
> > 
> > auto a = new Class();
> > 
> > So the diagnostic makes no sense..
> 
> class Class {}
> auto a = new Class();
> 
> testx.d(136): Error: variable testx.a is mutable. Only const or immutable class
> thread local variable are allowed, not testx.Class
> 
> Why doesn't it make sense?

I thought this had something to do with not allowing 'new'ing a class at
compile-time. I don't quite understand where the limitation for TLS
specifically came from, e.g.:

-----
class Class { }
static tls = new Class();  // NG
__gshared glob = new Class();  // ok

void main() { }
-----

Why is one allowed but not the other? And is this documented somewhere?

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


More information about the Digitalmars-d-bugs mailing list