www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22820] New: Error messages for slice pointers of structs with

https://issues.dlang.org/show_bug.cgi?id=22820

          Issue ID: 22820
           Summary: Error messages for slice pointers of structs with
                    opIndex can be improved
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: contact lsferreira.net

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)[]`

--
Feb 23 2022