[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

--- Comment #7 from ag0ae...@gmail.com ---
(In reply to Ryuichi OHORI from comment #6)
> I agree with you on closing this as invalid. The main problem was that I
> missed opIndexOpAssign and tried to use opIndex/opSlice (of a struct S) +
> opOpAssign (of the returning Voldemort type of S.opIndex).
>
> While I went wrong, the error message "cannot be sliced with []" is not so
> helpful as to help me figuring out the problem.

If I understand correctly, you're describing something like this:


struct V
{
void opOpAssign(string op)(int x) {}
}
struct S
{
V opIndex() {return V();}
}
void main()
{
S s;
s[] += 2; /* Error: S cannot be sliced with [] */
}


That error message really doesn't help. And it actually works when you use a
temporary variable to hold the result of s[]:


S s;
auto v = s[];
v += 2; /* no error */


So I'd say that's a rejects-valid bug. I filed issue 14941 for that.

> One of the reasons I missed opIndexOpAssign was that it is categorized under
> Op Assignment Operator Overloading. I'd like to place it under Array
> Indexing and Slicing Operators Overloading.

I don't know where it fits best. Maybe just make a pull request and see how it
goes.

--


[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

--- Comment #6 from Ryuichi OHORI  ---
I agree with you on closing this as invalid. The main problem was that I missed
opIndexOpAssign and tried to use opIndex/opSlice (of a struct S) + opOpAssign
(of the returning Voldemort type of S.opIndex).

While I went wrong, the error message "cannot be sliced with []" is not so
helpful as to help me figuring out the problem.

One of the reasons I missed opIndexOpAssign was that it is categorized under Op
Assignment Operator Overloading. I'd like to place it under Array Indexing and
Slicing Operators Overloading.

--


[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

ag0ae...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #5 from ag0ae...@gmail.com ---
(In reply to Ryuichi OHORI from comment #4)
> Ah, it seems I mis-minimized my code using older ones in
> http://dpaste.dzfl.pl/
> Here is an example 2.065 doesn't compile: 
> http://dpaste.dzfl.pl/fork/d52a0e0a2163
> I'm not sure but I was getting the same error

So the code works for you with a recent compiler (2.067, 2.068)?

I think code in the online docs doesn't need to be compatible with 2.065. So
I'm closing this as invalid. Please reopen if the code doesn't work for you
with 2.068, or generally if you disagree with me closing.

If you're getting that "cannot be sliced with []" error with different, valid
code, then please file a new bug.

--


[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

--- Comment #4 from Ryuichi OHORI  ---
Ah, it seems I mis-minimized my code using older ones in http://dpaste.dzfl.pl/
Here is an example 2.065 doesn't compile: 
http://dpaste.dzfl.pl/fork/d52a0e0a2163
I'm not sure but I was getting the same error

--


[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

--- Comment #3 from ag0ae...@gmail.com ---
(In reply to Ryuichi OHORI from comment #2)
> The version I used is 2.067.

Works for me with 2.067, too. What error are you getting?

--


[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

--- Comment #2 from Ryuichi OHORI  ---
The version I used is 2.067.

If this is a change it must be listed on ChangeLog anyway, but I couldn't find
it.

The document goes 'opIndex' for about an year, since this commit:
https://github.com/D-Programming-Language/dlang.org/commit/4af3111a5d1efb9dc79638d69bf87d9757a6a37b#diff-87ae512b433ac9f86b715f03fa17cb0eR691

--


[Issue 14935] [Operator Overloading] Wrong description on overloading a[]

2015-08-19 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14935

ag0ae...@gmail.com changed:

   What|Removed |Added

 CC||ag0ae...@gmail.com

--- Comment #1 from ag0ae...@gmail.com ---
Works for me with 2.068.0. What version of the compiler are you using? I think
things changed from opSlice to opIndex somewhat recently.

--