Skip to content

Commit 3c240c6

Browse files
committed
Fix hashmap construction (#78)
1 parent 95ff4ff commit 3c240c6

File tree

2 files changed

+138
-87
lines changed
  • ton-kotlin-hashmap/src/commonMain/kotlin/org/ton/hashmap
  • ton-kotlin-tlb/src/commonMain/resources

2 files changed

+138
-87
lines changed

ton-kotlin-hashmap/src/commonMain/kotlin/org/ton/hashmap/HashMapE.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public sealed interface HashMapE<T> : Iterable<Pair<BitString, T>>, TlbObject {
3434
public fun <T> fromMap(map: Map<BitString, T>?): HashMapE<T> {
3535
var hashMap = empty<T>()
3636
if (map == null) return hashMap
37+
var i = -1
3738
map.forEach { (key, value) ->
39+
require(!key.isEmpty()) { "Empty key" }
40+
if (i == -1) i = key.size
41+
else require(i == key.size) { "Variable length key, expected: $i, actual: (${key.size}) $key" }
3842
hashMap = hashMap.set(key, value)
3943
}
4044
return hashMap

0 commit comments

Comments
 (0)