Error message formatter for range primitives

WebFreak001 d.forum at webfreak.org
Tue Jan 11 14:36:47 UTC 2022


On Wednesday, 5 January 2022 at 09:32:36 UTC, Robert Schadek 
wrote:
> In 
> https://forum.dlang.org/post/tfdycnibnxyryizeckjp@forum.dlang.org I complained
> that error message related to range primitives like 
> isInputRange, especially on
> template constraints, are not great.
>
> [...]

cool!

As I'm not a fan of needing to refactor code I made my first DMD 
PR to try to make it possible to include this in phobos here: 
https://github.com/dlang/dmd/pull/13511

```d
source/app.d(43,5): Error: template `app.fun` cannot deduce 
function from argument types `!()(Sample1)`
source/app.d(22,6):        Candidates are: `fun(T)(T t)`
   with `T = Sample1`
   must satisfy the following constraint:
`       isInputRange!T: Sample1 is not an InputRange because:
                 the function 'popFront' does not exist`
source/app.d(24,6):                        `fun(T)(T t)`
   with `T = Sample1`
   must satisfy the following constraint:
`       isRandomAccessRange!T: Sample1 is not an 
RandomAccessRange because
                 the function 'popFront' does not exist
                 and the property 'save' does not exist
                 and must allow for array indexing, aka. [] access`
```


More information about the Digitalmars-d-announce mailing list