Bug 22820 – Error messages for slice pointers of structs with opIndex can be improved

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-23T11:32:49Z
Last change time
2022-03-03T10:56:05Z
Keywords
pull
Assigned to
No Owner
Creator
Luís Ferreira

Comments

Comment #0 by contact — 2022-02-23T11:32:49Z
Error messages for slice pointers without bounds can be improved to show an hint to the programmer to explicit dereference the pointer to access opIndex, e.g.: struct Atum { int[] opIndex() { return a; } int[] a; } int main() { Atum* atum = new Atum; writeln(atum[].ptr); } Should produce something like: Error: need upper and lower bound to slice pointer, perhaps you meant `(*atum)[]`
Comment #1 by dlang-bot — 2022-02-23T12:08:21Z
@ljmf00 created dlang/dmd pull request #13711 "Fix issue 22820: Improve error message for slice pointers" fixing this issue: - Fix issue 22820: Improve error message for slice pointers Signed-off-by: Luís Ferreira <[email protected]> https://github.com/dlang/dmd/pull/13711
Comment #2 by dlang-bot — 2022-03-03T10:56:05Z
dlang/dmd pull request #13711 "Fix issue 22820: Improve error message for slice pointers" was merged into master: - 26876a29b60bacb889d03c6007a92c4dc35deed2 by Luís Ferreira: Fix issue 22820: Improve error message for slice pointers Signed-off-by: Luís Ferreira <[email protected]> https://github.com/dlang/dmd/pull/13711