error diagnosis: range.algorithm(myFunc)
ZombineDev via Digitalmars-d
digitalmars-d at puremagic.com
Wed Dec 16 23:44:43 PST 2015
On Thursday, 17 December 2015 at 01:04:15 UTC, Luís Marques wrote:
> Hi,
>
> I often type `range.algorithm(myFunc)` instead of the correct
> `range.algorithm!(myFunc)`. Would it be possible to improve the
> error message for this? Something like the compiler spell
> checker, and ask "did you mean `range.algorithm!(myFunc)`?".
>
> That has happened sometimes with a non-UFCS call, but that's
> rarer, so just handling the UFCS case would bring most of the
> benefit, IMO.
I think it's not easy to make a general checker that can sugest
changing a run-time argument into a compile-time one.
A static assert should be flexible enough solution, but we would
need to make all of the template constraints into static asserts,
because otherwise the compiler will never reach the static assert
that would check if the type of the first run-time arg is not a
function.
More information about the Digitalmars-d
mailing list