Remove redundant attributes#2272
Conversation
There was a problem hiding this comment.
Wasn't this meant to be inout(T)* ? Your change seems to have flagged an issue?
There was a problem hiding this comment.
I don't know the intention of first author, but currently @property inout T* peek(T)() inout is exactly same with @property T* peek(T)() inout. So this PR changes nothing.
There was a problem hiding this comment.
Note that, the return statements in function body now return T*.
There was a problem hiding this comment.
Those returns ALSO have casts. It's pretty obvious that the casts should be removed. An immutable or const Variant should not return a mutable reference to itself.
This incorrectly compiles and runs without error with the existing compiler, and likely with your changes as well:
import std.variant;
void main()
{
immutable v = Variant(5);
assert(v == 5);
auto p = v.peek!int();
assert(p);
*p = 4;
assert(v == 4);
}Note: Variant really has no good support for being const or immutable, so I'm not even sure why it has any inout support anyway. I couldn't even print or get the value except (ironically) via peek.
|
OK, so it seems the code used to (incorrectly) compile because there was a cast. If I'm not mistaken, the code can be fixed, by simply removing the cast, and returning the correct @9rnsr : Would you mind making the fix? I realize you just wanted 3696 to pass, but (AFAIK) the intent of 3696 was specifically to catch these kinds of issues... |
|
I'm not sure it's relevant to this PR, at least for I'm inclined to say, let's pull this, and fix the Edit, not annotation issues, but the cast issues. |
Alright, works for me. Let's just not forget about them then. |
Remove redundant attributes
|
Thanks for merging. and I confirmed the issue. To fix it, I opened #2279. |
Required by: dlang/dmd#3696