为什么Eclipse有时会对JavaScript中的数组发出警告?

为什么Eclipse有时会对JavaScript中的数组发出警告?,javascript,arrays,eclipse,Javascript,Arrays,Eclipse,在Eclipse中,下面一行JavaScript var a1 = [[1, 2], [3, 4]]; 生成警告: Type mismatch: cannot convert from Number[] to any Type mismatch: cannot convert from Number[] to any 当 生成: Type mismatch: cannot convert from String[] to any Type mismatch: cannot convert f

在Eclipse中,下面一行JavaScript

var a1 = [[1, 2], [3, 4]];
生成警告:

Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from Number[] to any

生成:

Type mismatch: cannot convert from String[] to any
Type mismatch: cannot convert from String[] to any
Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from String[] to any

生成:

Type mismatch: cannot convert from String[] to any
Type mismatch: cannot convert from String[] to any
Type mismatch: cannot convert from Number[] to any
Type mismatch: cannot convert from String[] to any
但是,这些行都可以:

var a4 = [[1, 'x'], [3, 'y']];
var a5 = [[1, 2]];
var a6 = [['x', 'y']];

当子数组包含相同的基元类型时,数组的数组似乎有问题。然而,我不明白为什么,代码似乎执行正常。有人能解释一下Eclipse担心什么吗?

它看起来像个bug。Javascript中根本不存在类型不匹配的问题


我冒昧地猜测,正在执行此操作的解析器是基于Java解析器的,这是原始解析器的一部分。eclipse中的javascript验证器可以在首选项中筛选出这些参数。

关于此主题,只有我的.02$,但eclipse javascript引擎对此有点恼火。可能只是它运作中的一个怪癖。是eclipse中类似错误的一个例子。是的,我想你一定是对的。还有一些其他相当可疑的警告,例如“var i;for(obj中的i)”给出“局部变量i可能尚未初始化”。