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

Issue 6922 - [TDPL] superimposing of const and immutable does not work correctly #505

Merged
merged 2 commits into from
Nov 15, 2011

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Nov 10, 2011

static assert(is( inout(immutable(T)) == immutable(T) ));

static assert(is( inout(const(T)) == const(T) ));
static assert(is( const(inout(T)) == const(T) ));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines are not correct. const cannot override inout, because inout could mean immutable and immutable overrides const. inout cannot override const because inout could mean unqualified. Therefore inout(const(T)) and const(inout(T)) are effectively irreducible. (But the compiler should prefer one of them to the other, probably inout(const(T)).)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current dmd implementation does not allow that T has two modifiers const and inout at the same time.

And inout(T) is implicitly convertible to const(T), then I have thought inout(const(T)) should parsed as const(T).
Yes, this is an arbitrary rule. Instead, we can also select inout(T) as the parsing result of inout(const(T)).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see. That obviously also complicates the implementation of
http://d.puremagic.com/issues/show_bug.cgi?id=6930
Because there would have to be AST nodes for inout(const(T)) and shared(inout(const(T)).

See discussions of bug 6922 and 6930.
@WalterBright WalterBright merged commit c48777f into dlang:master Nov 15, 2011
braddr pushed a commit to braddr/dmd that referenced this pull request Oct 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants