In Eclipse, the following line of JavaScript
var a1 = [[1, 2], [3, 4]];
generates the warnings:
Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from Number[] to any
while
var a2 = [['w', 'x'], ['y', 'z']];
generates:
Type mismatch: cannot convert from String[] to any
Type mismatch: cannot convert from String[] to any
and
var a3 = [[1, 2], ['y', 'z']];
generates:
Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from String[] to any
However, these lines are all okay:
var a4 = [[1, 'x'], [3, 'y']];
var a5 = [[1, 2]];
var a6 = [['x', 'y']];
There seems to be a problem with arrays of arrays, when the sub-arrays contain the same primitive type. However, I don't understand why, and the code seems to execute okay. Can someone explain what Eclipse is worried about?
It looks like a bug. There is essentially no such thing as a type mismatch in Javascript.
I would hazard a guess that the parser that is doing this was based on a Java parser, and this is a bit of that original parser peeking through.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With