Confusing type error messages
Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=4534
Reported by Martin Stjernholm mast@roxen.com
Given this code:
class X1 {
string foo;
}
class X2 {
array(string) foo;
}
class Y1 {
void bar (X1 x);
}
class Y2 {
void bar (X2 x);
}
Y2 gnu (Y1 y) {return y;}
The compiler emits this error:
foo.pike:17:Wrong return type.
foo.pike:17:Expected: { Y2 = object(implements foo()->Y2) }
foo.pike:17:Got : { Y1 = object(implements foo()->Y1) }
foo.pike:17:Identifier bar is incompatible.
foo.pike:17:Expected: function({ X2 = object(implements foo()->X2) } : void)
foo.pike:17:Got : function({ X1 = object(implements foo()->X1) } : void)
foo.pike:17:Identifier foo is incompatible.
foo.pike:17:Expected: array(string)
foo.pike:17:Got : string
This provides nice info, but the message "Identifier foo is incompatible" could be more clear in where it has found foo, e.g. something like "Identifier foo in objects X1/X2 in argument 1 is incompatible". (In my real world case there was a foo in X1/X2 too which made it more confusing.)
Btw, an idle idea I got is to use the line info to point to the declarations:
foo.pike:17:Wrong return type.
foo.pike:17:Expected: { Y2 = object(implements foo()->Y2) }
foo.pike:17:Got : { Y1 = object(implements foo()->Y1) }
foo.pike:17:Identifier bar in objects Y2/Y1 is incompatible.
foo.pike:14:Expected: function({ X2 = object(implements foo()->X2) } : void)
foo.pike:10:Got : function({ X1 = object(implements foo()->X1) } : void)
foo.pike:17:Identifier foo in objects X2/X1 in argument 1 is incompatible.
foo.pike:6:Expected: array(string)
foo.pike:2:Got : string