D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10649 - immutable/const aggregate definitions not consistent
Summary: immutable/const aggregate definitions not consistent
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-15 12:07 UTC by Dicebot
Modified: 2024-12-13 18:09 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dicebot 2013-07-15 12:07:17 UTC
immutable struct A
{
	struct B
	{
		int x;
	}
	
	int x;
	static int y;
}

void main()
{
	A.y = 42; // works
	A a;
	// a.x = 42; // fails
	A.B b;
	b.x = 42; // works
}

-------------------------------------

Applying const/immutable qualifier to aggregate definition propagates it only to fields and methods of struct/class. static fields and nested definitions are left mutable which is extremely confusing and inconsistent with usual transitivity.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:09:30 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18632

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB