Help improve error message
Steven Schveighoffer
schveiguy at gmail.com
Mon May 8 12:09:16 UTC 2023
On 5/7/23 11:31 PM, ryuukk_ wrote:
>
> You don't understand, my complain isn't about UFCS, it's about the error
> message that is misleading when trying to debug a problem in your
> project, the compiler never gives you the hint that ``Something``
> doesn't have a ``get`` function, it tells you that in some other places
> it doesn't match any overload, it's perhaps time saved when you were
> looking to use an UFCS function, but it is time wasted when you were
> looking to call a function from `Something`
I take the "no overloads match for function in unrelated module" to mean
the function doesn't exist as a method. If there was even one `get`
method, then it would not even look for other functions.
This is somewhat par for the course in languages that have overload
resolution. It found something by that name, but couldn't make it work.
The unique part about D is that those functions can be outside the type
even though they look like they are method calls.
>
>
> I perhaps expect the following error message:
>
>
> ```
> onlineapp.d(6): Error: no property `get` for `test` of type `Something`
> onlineapp.d(6): Note: The following UFCS functions where found:
>
> /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(3442):
> `get(K, V)(inout(V[K]) aa, K key, lazy inout(V) defaultValue)`
> /dlang/dmd/linux/bin64/../../src/druntime/import/object.d(3449):
> `get(K, V)(inout(V[K])* aa, K key, lazy inout(V) defaultValue)`
>
> onlineapp.d(6): Error: none of the overloads of template `object.get`
> are callable using argument types `!()(Something)`
> ```
Once you get used to UFCS, you will understand these error messages easier.
But the compiler can always use clearer error messages.
> If your language has good feature, diagnostics should match, otherwise
> it's like with this global that can't be debugged, you perhaps learned
> to live with it, i haven't and refuse to do so
Not being able to debug the global is an actual bug though, not a
language design feature.
My comment on it was that I don't really use debuggers, even for other
languages. I didn't "learn to live with it", I just never needed it.
-Steve
More information about the Digitalmars-d
mailing list