Bug report: iteration on dicts fails if index var is not used
Attila Szegedi
attila.szegedi at oracle.com
Mon Aug 25 08:47:45 UTC 2014
Thanks, I recorded this as <https://bugs.openjdk.java.net/browse/JDK-8055870> It seems to be related to the static local variable type inference logic that I'm responsible for. I'll look into this ASAP. We just pushed a backport of JDK 9 optimistic typing feature to 8u-dev, and local static type inference is part of that.
I'll also try to figure out internally who's resposible for the bugreport page and see to it that a "Nashorn" subcategory gets added.
Attila.
On Aug 25, 2014, at 6:26 AM, Tal Liron <tal.liron at threecrickets.com> wrote:
> Sorry for using the mailing list, still unclear for me how to open Nashorn bugs (the standard form in bugreport.java.com does not have a "nashorn" subcategory). The bug is on trunk in http://hg.openjdk.java.net/jdk8u/jdk8u-dev/nashorn.
>
> The following program will cause an exception when "isEmpty2" is called:
>
> Error: java.lang.ClassCastException: java.lang.String cannot be cast to jdk.nashorn.internal.runtime.Undefined
>
> The only difference between isEmpty1 and isEmpty2 is the actual use of "k". If "k" is not referenced, the exception happens.
>
>
> function isEmpty1(v) {
> for (var k in v) {
> print(v[k]+'\n')
> return false
> }
> return true
> }
>
> function isEmpty2(v) {
> for (var k in v) {
> return false
> }
> return true
> }
>
> x = {test: 'test'}
>
> isEmpty1(x)
> isEmpty2(x)
>
More information about the nashorn-dev
mailing list