On 29 March 2011 21:33, Rodrigo Rivas wrote: > On Tue, Mar 29, 2011 at 8:22 PM, Jonathan Wakely <jwakely....@gmail.com> > wrote: >> How about "No suitable %<begin%> and %<end%> functions found for range >> expression of type %qT in %<for%> statement" ? > > Nice. > But the problem here is that there are a lot of different error conditions: > 1. begin member but not end member. > 2. end member but not begin member.
I think these cases should say something like "invalid lookup results, member 'begin' and non-member 'end'" (or vice versa) as we had in last week's patch. Or maybe it would be better to say "lookup for 'for' found member 'begin' but no member 'end'" > 3. begin and end member but one or both are not callable/accesible/whatever. I would definitely want to get an "access denied", "deleted function" etc. error for that case. > 3. no begin/end members, a begin global function but not end. > 4. no begin/end members, an end global function but not begin. Maybe something similar to the text I suggested above, but only mentioning the lookup that failed, "no suitable 'begin' found for range expression ..." > 5. no begin/end members, begin and end functions but one or both not > callable/wrong overload/etc. In some cases I would probably want to know the actual error, not just "cannot use range-based for" If a begin() is found but can't be called, showing the "candidates are..." list might be helpful to see the problem e.g. if my::begin(my::type&) can't be called for const my::type. > 6. no begin/end members, no begin/end global functions. Since the > standard headers have the std::begin/std::end templates, this will not > happen when you include (most) STL headers. Maybe this is the only case where the text I suggested is useful, I think a special "can't use range-based for" makes sense in this case, instead of "begin not declared in this scope" > What is the best message for each? Does it make sense to have up to 6 > different messages? Too many? It would be nice for users, but it's certainly more work, and potentially more places for bugs to creep in.