Bug 22417 – Slice assignment operator overloading example is incorrect

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-10-18T03:50:25Z
Last change time
2021-10-18T05:40:25Z
Keywords
pull
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2021-10-18T03:50:25Z
The example in the language spec under "Slice Assignment Operator Overloading" [1] is incorrect. Specifically, it claims that the following rewrite is performed: --- a[3..4] = v; // same as a.opIndexAssign(v, a.opSlice(3,4)); --- However, using the -vcg-ast compiler switch reveals that this statement is actually rewritten as follows: --- a.opSlice(3LU, 4LU)[] = v; --- This is because the D2-style opSlice overload is declared incorrectly: it does not accept a `dim` template parameter, as specified in the section on "Slice Operator Overloading" [2], and it returns an `int[2]` rather than the `size_t[2]` expected by the opIndexAssign overload. [1] https://dlang.org/spec/operatoroverloading.html#slice_assignment_operator [2] https://dlang.org/spec/operatoroverloading.html#slice
Comment #1 by dlang-bot — 2021-10-18T04:10:06Z
@pbackus created dlang/dlang.org pull request #3113 "Fix issue 22417 - Slice assignment operator overloading example is in…" fixing this issue: - Fix issue 22417 - Slice assignment operator overloading example is incorrect Also update the surrounding exposition to match the corrected example, and change some identifiers in the example to match the notation used in the exposition and the comments. https://github.com/dlang/dlang.org/pull/3113
Comment #2 by dlang-bot — 2021-10-18T05:40:25Z
dlang/dlang.org pull request #3113 "Fix issue 22417 - Slice assignment operator overloading example is in…" was merged into master: - 253e2de13e109add6b97cd5231cd90db46d327e4 by Paul Backus: Fix issue 22417 - Slice assignment operator overloading example is incorrect Also update the surrounding exposition to match the corrected example, and change some identifiers in the example to match the notation used in the exposition and the comments. https://github.com/dlang/dlang.org/pull/3113