www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20673] New: Improve error message for opDollar in pointers

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

          Issue ID: 20673
           Summary: Improve error message for opDollar in pointers
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

A very common beginner mistake:
```
void main ()
{
    int* ptr;
    assert(ptr[0 .. $] == [1, 2, 3]);
}
```

This will yield the following message:
```
diagxxx.d(4): Error: undefined identifier __dollar
```

Not quite as informative as it could be. This could be a good starting task for
someone wanting to touch DMD. The error is produced here:
https://github.com/dlang/dmd/blob/631473e8746050bd743fe238ba343c079e0f25e0/src/dmd/expressionsem.d#L2721

--
Mar 15