Bug 5200 – Call to immutable method during immutable construction

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-11-11T01:39:13Z
Last change time
2021-03-19T07:48:32Z
Assigned to
No Owner
Creator
jens.k.mueller

Comments

Comment #0 by jens.k.mueller — 2010-11-11T01:39:13Z
According to TDPL p. 294 a call to any non-static method in an immutable constructor is not allowed. But class A { int a; this() immutable { a = 5; fun(); // should not compile } void fun() immutable {} } compiles with dmd v2.050. I think the behavior should be clarified. Either in dmd to match TDPL or the other way round. I'm going to add a link to a thread on [email protected] for further information.
Comment #1 by jens.k.mueller — 2010-11-16T09:28:38Z
Comment #2 by braddr — 2011-02-06T15:40:16Z
Mass migration of bugs marked as x86-64 to just x86. The platform run on isn't what's relevant, it's if the app is a 32 or 64 bit app.
Comment #3 by razvan.nitu1305 — 2021-03-19T07:48:32Z
I don't have the book, so I don't know exactly what it says at page 294, however the code posted here is perfectly legal. I assume that maybe the book is referring to static constructors, in which case it makes sense. Anyway, I'm closing this issue as invalid.