Fix VmDynamicCursor (#1948)
This fixes an issue where it fails to iterate over this entry:
`new Dynamic { [-1] = 2 }`
This commit is contained in:
1 parent
b1b36b09ac
commit
5cb5d41a44
3 files changed
+17
-6
No files matched your search
@@ -102,7 +102,7 @@ final class VmDynamicCursors {
|
||||
|
||||
@Override
|
||||
protected boolean shouldVisit(Object key) {
|
||||
return key instanceof Long l && l < iteratee.getLength();
|
||||
return key instanceof Long l && l >= 0 && l < iteratee.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +121,7 @@ final class VmDynamicCursors {
|
||||
if (member.isProp()) {
|
||||
return false;
|
||||
}
|
||||
return !(key() instanceof Long l) || l >= iteratee.getLength();
|
||||
return !(key() instanceof Long l) || l < 0 || l >= iteratee.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +140,7 @@ final class VmDynamicCursors {
|
||||
if (member.isProp()) {
|
||||
return false;
|
||||
}
|
||||
return !(key() instanceof Long l) || l >= iteratee.getLength();
|
||||
return !(key() instanceof Long l) || l < 0 || l >= iteratee.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +157,7 @@ final class VmDynamicCursors {
|
||||
@Override
|
||||
protected boolean shouldVisit(Object key) {
|
||||
if (key instanceof Identifier) return false;
|
||||
if (key instanceof Long l) return l >= iteratee.getLength();
|
||||
if (key instanceof Long l) return l < 0 || l >= iteratee.getLength();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ final class VmDynamicCursors {
|
||||
|
||||
@Override
|
||||
public boolean isElement() {
|
||||
return key() instanceof Long l && l < iteratee.getLength();
|
||||
return key() instanceof Long l && l >= 0 && l < iteratee.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -210,7 +210,7 @@ final class VmDynamicCursors {
|
||||
|
||||
@Override
|
||||
public boolean isElement() {
|
||||
return key() instanceof Long l && l < iteratee.getLength();
|
||||
return key() instanceof Long l && l >= 0 && l < iteratee.getLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -115,6 +115,12 @@ examples {
|
||||
map1.toDynamic()
|
||||
}
|
||||
|
||||
["toDynamic() round-trip"] {
|
||||
Map(-1, 2).toDynamic().toMap()
|
||||
Map(0, 2).toDynamic().toMap()
|
||||
Map(1, 2).toDynamic().toMap()
|
||||
}
|
||||
|
||||
["toMapping()"] {
|
||||
Map().toMapping()
|
||||
map1.toMapping()
|
||||
|
||||
@@ -96,6 +96,11 @@ examples {
|
||||
three = 3
|
||||
}
|
||||
}
|
||||
["toDynamic() round-trip"] {
|
||||
Map(-1, 2)
|
||||
Map(0, 2)
|
||||
Map(1, 2)
|
||||
}
|
||||
["toMapping()"] {
|
||||
new {}
|
||||
new {
|
||||
|
||||
Reference in new issue
Block a user