D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5200 - Call to immutable method during immutable construction
Summary: Call to immutable method during immutable construction
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-11 01:39 UTC by jens.k.mueller
Modified: 2021-03-19 07:48 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 jens.k.mueller 2010-11-11 01:39:13 UTC
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 digitalmars-d@puremagic.com for further information.
Comment 2 Brad Roberts 2011-02-06 15:40:16 UTC
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 RazvanN 2021-03-19 07:48:32 UTC
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.