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

Loop in class building prevent compiler termination #55

Open
trethaller opened this issue Mar 5, 2021 · 6 comments
Open

Loop in class building prevent compiler termination #55

trethaller opened this issue Mar 5, 2021 · 6 comments

Comments

@trethaller
Copy link
Contributor

When a serializable class ends-up referencing itself in its graph of references, this error can occur:
Loop in class building prevent compiler termination

The current workaround is to declare the reference of an more abstract type, eg, Serializable, and add strongly typed get/set.

Should this be standardized? For example:

@:s(sub) var subRef : MyClass;

@:storeAs(ParentClass) @:s var subRef : MyClass;

@:selfRef @:s var subRef : MyClass;

@trethaller
Copy link
Contributor Author

Any preference ?

@ncannasse
Copy link
Member

Ideally this should be done automatically without the user having to tag such cases.

@trethaller
Copy link
Contributor Author

What would be the downside of systematically storing vars as Serializable and performing casts in the get/set functions?

@ncannasse
Copy link
Member

ncannasse commented Apr 21, 2021 via email

@trethaller
Copy link
Contributor Author

I'm wondering how much of a problem that is for ref fields. I see that it would be too bad for things like x,y,z, but not sure we actually have performance critical code using @:s refs?
I don't think using to the abstract type automatically when a loop is detected is a good idea: if the casting cost is a problem, then it would be very opaque for the user why some fields have it and some don't.
So unless we are okay with the type checks being there for all refs (which I'm not sure is really a problem?) I don't see a better way than to flag fields manually. The hardest part being finding a name that makes sense 😂

@ncannasse
Copy link
Member

I would need a reproducible example so I can fix that :)

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

2 participants