Closed olichose123 closed 3 years ago
Seems to be a compilation problem after all, related to https://github.com/HaxeFoundation/haxe/issues/8368. Not the fault of this lib.
Hi, can you still reproduce this easily? I'm working on the haxe issue you mentioned, and need a few different reproduction samples.
No problem. Will come back with my latest attempt.
It looks like I cannot replicate this with Haxe 4.2.5 and json2object 3.10.0. I'm guessing the underlying macro bug has been fixed, or somehow there was a problem with my environment (though I would later discover it used to happen on multiple computers when playing with macros, not only with this lib).
So I'd consider this one fixed/not a problem. I'm really happy that it now works correctly and should have tried it months ago!
@kLabz I can reproduce this on haxe 4.2.5 and json2object 3.10.0
It happens when I define a reader and a writer of anonymous structures in two different classes as static variables, separate files. If they are in the same file I think there is no problem, most of the time
However, it is unstable and changing related files a bit + recompiling fixes the issue. Sometimes.
Hi @Pidroh, thanks! Indeed I can reproduce on both 4.2.5 and nightlies.
The issue is not a Haxe compiler issue; DataBuilder is not compiler cache safe. Issue can be dodged by adding @:persistent
to DataBuilder
's counter
.
cc @elnabo
Edit: There's a Haxe compiler generated X is redefined from X issue happening in some cases (while editing DataBuilder) after fixing this, when using a nightly older than https://github.com/HaxeFoundation/haxe/commit/b3b3d6b48a39b2c5a40b0fd137868dd81827e179. More recent nightlies and 4.2.5 are fine.
@kLabz Made a pull request, did not test it https://github.com/elnabo/json2object/pull/85
Would that fix the problem?
The fix should now be available with version 3.11.0 on haxelib.
@kLabz Hii, that fix wasn't enough, I still get the error sometimes :(
sometimes I also get
Uncaught ReferenceError: JsonParser_$11 is not defined
when running the game on the browser (building to Javascript)
Do you think the problem is also happening somewhere else?
@kLabz do you mean that this @:persistent
fix can be #if defined
for Haxe <4.3?
With this counter increment after every server compilation this is annoying to check diffs of target codes, all types change with JsonParser_$678
stuff.
Also, reproducible example of this bug would be nice to see.
I often get this strange compilation bug that nothing can fix but a reload of vscode and I'm not sure why it happens.
Type name JsonParser_1 is redefined from module JsonParser_1
injson2object\3,9,0\src\json2object\reader
at line 396.So far any simple use of json2object will generate this error in any single project. The fact that I could not find a similar issue and that a restart of vscode might indicate that it is caused by the compilation of hl and not json2object itself, but others might have an idea of what it is.