Help improve error message

ryuukk_ ryuukk.dev at gmail.com
Mon May 8 03:31:10 UTC 2023


On Monday, 8 May 2023 at 02:55:57 UTC, Steven Schveighoffer wrote:
> On 5/7/23 8:50 PM, ryuukk_ wrote:
>> On Sunday, 7 May 2023 at 14:19:49 UTC, Steven Schveighoffer 
>> wrote:
>> 
>>>> Well.. it's not what you expect..
>>>
>>> Depends ;) I've been using D long enough that it's exactly 
>>> what I expected.
>> 
>> 
>> See.. that's were my expectation of this language seems to be 
>> non-compatible with the majority of you, and that's super 
>> unfortunate because there is nothing i can do to change things
>> 
>> ``Something`` is a struct, and you are telling me that it is 
>> normal for D to treat it as a associative array
>
> No, it's normal that the name `get` when not defined on a type 
> then tries UFCS. And because I know `get` is a UFCS function in 
> `object.d`, it will pick that up instead of saying "no such 
> function".
>
> What if `Something` had a function called `get`, but it didn't 
> take the parameters you sent it? Would it be acceptable to you 
> if it said "no function named `get`" instead of detailing why 
> the parameters don't match? That's basically what you are 
> asking.
>
>> With that kind of expectation, i now understand better why the 
>> .enum DIP got shut down, language is stuck in the past with no 
>> way to improve anything, including this type identity crisis
>
> This is unrelated. UFCS is a fabulous feature of the language, 
> and understanding the way it works is crucial in order to 
> understand the confusing error messages you might see. Not that 
> it's always ideal, but I'll take confusing messages and UFCS 
> over the alternative without UFCS any day.
>
> FWIW, I was in favor of the enum DIP and think the reasons for 
> rejection were invalid. But I've also been here long enough to 
> know when arguing over the dead horse isn't worth my time.
>
> -Steve

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 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)`
```

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




More information about the Digitalmars-d mailing list