non-lambda overloads for lambda-only things

Steven Schveighoffer schveiguy at gmail.com
Sat Apr 17 01:02:33 UTC 2021


On 4/16/21 4:36 PM, tsbockman wrote:
> 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.

Yes please! Can someone do this? Would be way better than the phobos 
hack I am thinking of.

-Steve


More information about the Digitalmars-d mailing list