Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataBuilder error "Type name JsonParser_1 is redefined from module JsonParser_1" once in a while #74

Closed
olichose123 opened this issue Jun 1, 2021 · 11 comments

Comments

@olichose123
Copy link

olichose123 commented Jun 1, 2021

I often get this strange compilation bug that nothing can fix but a reload of vscode and I'm not sure why it happens.
image

Type name JsonParser_1 is redefined from module JsonParser_1 in json2object\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.

@olichose123
Copy link
Author

Seems to be a compilation problem after all, related to HaxeFoundation/haxe#8368. Not the fault of this lib.

@kLabz
Copy link
Contributor

kLabz commented Jan 11, 2023

Hi, can you still reproduce this easily?
I'm working on the haxe issue you mentioned, and need a few different reproduction samples.

@olichose123
Copy link
Author

No problem. Will come back with my latest attempt.

@olichose123
Copy link
Author

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!

@Pidroh
Copy link
Contributor

Pidroh commented Feb 1, 2023

@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

@Pidroh
Copy link
Contributor

Pidroh commented Feb 1, 2023

However, it is unstable and changing related files a bit + recompiling fixes the issue. Sometimes.

@kLabz
Copy link
Contributor

kLabz commented Feb 1, 2023

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 HaxeFoundation/haxe@b3b3d6b. More recent nightlies and 4.2.5 are fine.

Pidroh added a commit to Pidroh/json2object that referenced this issue Feb 1, 2023
Pidroh added a commit to Pidroh/json2object that referenced this issue Feb 1, 2023
@Pidroh
Copy link
Contributor

Pidroh commented Feb 1, 2023

@kLabz
Made a pull request, did not test it
#85

Would that fix the problem?

elnabo pushed a commit that referenced this issue Feb 2, 2023
elnabo pushed a commit that referenced this issue Feb 2, 2023
@elnabo
Copy link
Owner

elnabo commented Feb 21, 2023

The fix should now be available with version 3.11.0 on haxelib.

@Pidroh
Copy link
Contributor

Pidroh commented Mar 8, 2023

@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?

@RblSb
Copy link

RblSb commented Apr 7, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants