non-lambda overloads for lambda-only things

tsbockman thomas.bockman at gmail.com
Fri Apr 16 20:36:02 UTC 2021


On Thursday, 15 April 2021 at 22:02:10 UTC, Steven Schveighoffer 
wrote:
> To instead get a better error message:
>
> Error: static assert:  "You didn't mean to do this. Make your 
> lambda a template parameter"
>
>  Is this worth adding to Phobos?

Rather than adding a bunch of boiler plate to every generic 
library to get better error messages, why not make the compiler 
do it automatically?

Whenever the compiler generates an error message due to failure 
of function overload resolution and only runtime arguments were 
supplied (syntactically), the compiler could first test whether 
overload resolution would have succeeded if a `!` had been 
included to mark them as template arguments, instead.

It should still be an error either way, but in the latter case a 
"did you mean ...?" suggested resolution could be included in the 
message.

This generally shouldn't slow down compilation meaningfully, 
since it only triggers when the compilation is going to fail and 
skip code generation, etc. anyway.


More information about the Digitalmars-d mailing list