Not sure if reported already (bad code generation ...
# javascript
d
Not sure if reported already (bad code generation in 1.2.20, related to longs and ranges): https://github.com/korlibs/korio/blob/01d5ef0b03094620ae5fa8194c0b0848d04d7170/korio/common/src/main/kotlin/com/soywiz/korio/stream/SyncStream.kt#L169
Copy code
MemorySyncStreamBase.prototype.read_4m9kcn$ = function (position, buffer, offset, len) {
    var tmp$;
    this.checkPosition_s8cxhz$(position);
    tmp$ = this.length;
    if (!((0).lessThanOrEqual(position) && position.lessThan(tmp$)))
      return 0;
    var end = min(Math_0, this.length, position.add(Kotlin.Long.fromInt(len)));
    var a = end.subtract(position).toInt();
    var actualLen = Math_0.max(a, 0);
    arraycopy(this.data.data, position.toInt(), buffer, offset, actualLen);
    return actualLen;
  };
0.lessThanOrEqual(position) <--
Copy code
if (!((0).lessThanOrEqual(position) && position.lessThan(tmp$)))
return 0;
Copy code
TypeError: 0.lessThanOrEqual is not a function
      at MemorySyncStreamBase.read_4m9kcn$ (korio-js.js:23710:15)
      at SliceSyncStreamBase.read_4m9kcn$ (korio-js.js:23581:30)
      at SyncStream.read_mj6st8$ (korio-js.js:23499:26)
      at readBytes_0 (korio-js.js:23847:36)
      at readString_0 (korio-js.js:23805:23)
      at ImageFormats.readImage_1ooaqm$$default (korim-js.js:6284:85)
      at ImageFormats.ImageFormat.readImage_1ooaqm$ (korim-js.js:5666:65)
      at ImageFormats.ImageFormat.read_zdd1ed$ (korim-js.js:5759:17)
      at Coroutine$ImageFormat$decodeInWorker$lambda.doResume (korim-js.js:5933:48)
      at korim-js.js:5911:25
      at KorioNative.executeInWorker_lnyleu$ (korio-js.js:38407:12)
      at executeInWorker (korio-js.js:6831:38)
      at ImageFormats.ImageFormat.decodeInWorker_nwlife$ (korim-js.js:5953:12)
      at Coroutine$readBitmapNoNative_0.doResume (korim-js.js:9536:48)
      at Coroutine$readBitmapNoNative_0.CoroutineImpl.doResumeWrapper_0 (kotlin.js:3630:27)
a
Looks like a bug in range-check optimization. The workaround for now would be to replace
0
with
0L
, i.e.:
if (position !in 0L until length) return 0
👍 1
d
Ok. Thanks!
a
I don't see it in the bug tracker, could you report it?
d
Sure
a
Thanks!
d
a
Thanks!