HeapsIO / hxbit

Haxe Binary serialization and network synchronization library
155 stars 30 forks source link

Std.instance doesnt work on js #23

Closed RblSb closed 5 years ago

RblSb commented 6 years ago

https://github.com/ncannasse/hxbit/blob/master/hxbit/NetworkHost.hx#L584 When o is Cursor instance, n is null on js target (Heaps Network sample). After replacing it with safe cast, the code worked with my WebSocketHost. I think this should be replaced with safe/unsafe cast in try/catch at least for JS? The docs says "This method is not guaranteed to work with interfaces". Another using of Std.instance here.

RblSb commented 6 years ago

Oh, i found #18 now. And actual issue is HaxeFoundation/haxe/issues/5946. Maybe leave this issue open until fix?

ncannasse commented 6 years ago

Closing, the JS issue will be fixed for Haxe 4.0

RblSb commented 5 years ago

@ncannasse I guess after https://github.com/HaxeFoundation/haxe/pull/7658 merge these lines should use cast instead of Std.instance for haxe 4?

ncannasse commented 5 years ago

Right, we should use a Std.is + unsafe cast, as Std.instance on interfaces are not guaranteed.

ncannasse commented 5 years ago

In latest Haxe 4 , Std.instance (now Std.downcast) is well specified and tested for interfaces as well.