Help improve error message
RazvanN
razvan.nitu1305 at gmail.com
Mon May 8 08:18:21 UTC 2023
On Saturday, 6 May 2023 at 23:28:58 UTC, max haughton wrote:
> On Saturday, 6 May 2023 at 20:02:30 UTC, ryuukk_ wrote:
>> [...]
>
> This wouldn't be that hard to do but then you have a tradeoff
> between making this cleaner and making other contexts more
> confusing.
>
> On the compiler side it would be interesting to make it output
> some kind of prose based on some kind of type pattern matching
> / unification e.g. rather than saying "Cannot call X with Y",
> we'd have a much more contextual error message that uses the
> information in the template signature (e.g. for `(K,
> V)(inout(V[K])` to be matched, it must satisfy the pattern, so
> must be an AA of type V[K]).
>
> There's a dlang/projects entry for error messages, this would
> make a good thing to be done in that project.
>
> As for the runtime, I'm not a big fan of these free functions
> either.
Yes, I think that `get` should not be directly callable but
rather the compiler should insert a call to it. That way you can
call it something else in druntime (__getAAKey or somrthing like
that) and the compiler can lower to it in case the lhs of the dot
expression is an associative array. It adds a bit of complexity
in the compiler, but it gets rid of these weird error messages.
More information about the Digitalmars-d
mailing list