Incomprehensible error message
H. S. Teoh
hsteoh at quickfur.ath.cx
Mon Mar 19 18:03:31 UTC 2018
On Mon, Mar 19, 2018 at 05:01:32PM +0000, Adam D. Ruppe via Digitalmars-d-learn wrote:
> On Monday, 19 March 2018 at 16:33:28 UTC, Russel Winder wrote:
> > I have been staring at this message so long, I have clearly stopped
> > actually reading it, hence outside assistance needed.
>
> So I would guess either there's two definitions of one of the types
> like maybe `dvb_v5_fe_parms` and the constructor uses one and your
> code uses another (may be the same struct defined in two different
> modules, where the definition imported one and you imported another -
> stupid compiler was (is?) liable to say "type A is not type A" when it
> should say "type foo.A is not bar.A"), or something like a stray const
> on the `this` pointer.
>
>
> I almost remember that A != A bug was fixed but maybe not in function
> call things, or maybe not pushed to your ldc version yet.
Yeah, the compiler really ought to be outputting FQNs in error messages,
since otherwise you get baffling A != A messages. Though outputting
FQNs everywhere has the tendency of bloating error messages to
unreadable lengths, esp. when templates are involved. :-( (Though
fortunately, no templates are involved in this case.)
On a higher level, though, these type mismatch errors really ought to be
refactored to pinpoint the cause of the compiler's unhappiness more
narrowly, i.e., instead of saying:
function F(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v) is not
callable with parameter types
(a,b,c,d,e,f,g,h,j,i,k,l,m,n,o,p,q,r,s,t,u,v)
which requires the poor user to parse *two* entire incomprehensibly long
parameter/argument lists and diff them in his head, the compiler really
should say something more along the lines of:
cannot pass argument j of type J to parameter 9 of type I and
argument i of type I to parameter 10 of type J in function call
to F(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v)
The incomprehensibly long parameter list is unfortunately probably still
necessary to identify any overloads of F, but at least point out to the
user *which* parameters aren't matching instead of leaving him to figure
it out!
T
--
IBM = I'll Buy Microsoft!
More information about the Digitalmars-d-learn
mailing list