Skip to content

Don't use a mem reference for setting object fields#1324

Open
Aidan63 wants to merge 1 commit intoHaxeFoundation:masterfrom
Aidan63:cppia-lookup-objs
Open

Don't use a mem reference for setting object fields#1324
Aidan63 wants to merge 1 commit intoHaxeFoundation:masterfrom
Aidan63:cppia-lookup-objs

Conversation

@Aidan63
Copy link
Contributor

@Aidan63 Aidan63 commented Mar 22, 2026

The mem reference erases the underlying type to just hx::Object*, this is a problem when you try and set a field of a function type in a host class from a script. Script closures and functions do not extend the new callable type so by using this type erased pointer is assigned a not callable object to a callable object pointer, which then causes memory errors when invoking it.

@tobil4sk
Copy link
Member

Will this have an impact on performance?

@Aidan63
Copy link
Contributor Author

Aidan63 commented Mar 22, 2026

Probably, the removed code means updating a field which contains an object will use runtime lookup.
A narrower fix would be to update the TypeData object to contain extra info if the object is a function (it already does this for array types), we could then use that to only opt out of the pointer method of the object field is for a function.
This work around is also only needed for host and script interactions, if it's purely script based then it's not needed, so there's probably further narrowing which could be done there (assuming it's possible to detect those cases).

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

Successfully merging this pull request may close these issues.

2 participants