benmerckx / genes

Generates split ES6 modules and Typescript definitions from Haxe modules.
44 stars 8 forks source link

untyped haxe.ds.ObjectMap.getId() #12

Closed kevinresol closed 4 years ago

kevinresol commented 4 years ago

Sorry dunno how to write a title for this. This basically comes from a rather hackish piece of code:

untyped haxe.ds.ObjectMap.getId(key)

This when compiled with Haxe, it is inlined into key.__id__

but with genes it doesn't get inlined and remains ObjectMap.getId, causing runtime error because the field getId does not exist.

cc @back2dos

benmerckx commented 4 years ago

Genes is bundled with a native js map implementation (without getId): https://github.com/benmerckx/genes/blob/master/src/haxe/ds/ObjectMap.hx The main reason for using the native javascript map was honestly because I didn't feel like dealing with the whole __map_reserved thing. There's also https://github.com/HaxeFoundation/haxe/pull/8909 which is not available in the stable releases yet but will do away with getId/assignId as well.

kevinresol commented 4 years ago

ok I will patch in coconut instead

binki commented 4 years ago

There's also HaxeFoundation/haxe#8909 which is not available in the stable releases yet but will do away with getId/assignId as well.

I don’t think that PR gets rid of getId/assignId. Those functions only apply to ObjectMap. That PR is for StringMap which only supports string keys. That PR does support removing __map_reserved when targeting ES5. However, since hasOwnProperty is in ES3 I don’t get why they require ES5 for that…

getId/assignId could only be removed if targeting ES6 and reimplementing ObjectMap in terms of ES6 Map.