Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

immutable/const aggregate definitions not consistent #18632

Open
dlangBugzillaToGithub opened this issue Jul 15, 2013 · 0 comments
Open

immutable/const aggregate definitions not consistent #18632

dlangBugzillaToGithub opened this issue Jul 15, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Dicebot (@mihails-strasuns) reported this on 2013-07-15T12:07:17Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=10649

Description

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant