haxe icon indicating copy to clipboard operation
haxe copied to clipboard

[js] String.prototype.__class__ readonly exception when mixing Haxe 4.2.x and Nightly js output

Open AlexHaxe opened this issue 3 years ago • 0 comments

since releasing vshaxe compiled with Haxe nightly all other Haxe plugins fail to initialise with a stacktrace that starts with: TypeError: Cannot assign to read only property '__class__' of object '[object String]' (see vshaxe/vshaxe#534). mixing js code compiled with Haxe 4.2.x and nightlies seems to be the cause: nightly produces Object.defineProperty(String.prototype,"__class__",{ value : String, enumerable : false}); whereas Haxe 4.2.5 generates: String.prototype.__class__ = String;

given that ObjectPropertyDescriptor parameter of defineProperty has writable: false as its default, accessing String.prototype.__class__ directly (in the Haxe 4.2.5 way), results in a read only exception.

it's probably a very unique issue and might be limited to vscode (where all plugins seem to run in the same nodejs instance), but it might also occur in other scenarios.

obvious fix is to recompile all plugins with Haxe nightly and release an update

steps to reproduce:

  • install vshaxe 2.24.0
  • install codedox
  • close all editor windows (or move to a non Haxe editor window)
  • restart vscode / reload window
  • open any Haxe file
  • switch to OUTPUT tab and select Log (Extension Host)
  • look for codedox initialisation messages (should be pretty obvious with a stacktrace and red [error] in front of it)

AlexHaxe avatar Jul 03 '22 13:07 AlexHaxe