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

Redundant call _hx_funcToField for lua target #11842

Open
ze0nni opened this issue Nov 25, 2024 · 1 comment
Open

Redundant call _hx_funcToField for lua target #11842

ze0nni opened this issue Nov 25, 2024 · 1 comment
Labels
platform-lua Everything related to Lua

Comments

@ze0nni
Copy link

ze0nni commented Nov 25, 2024

I profiled my code and found this strange behavior.

package;

typedef Slot = {
        var data: Int;
}

class Main {
        static function main() {}

        static function foo(a: Slot, b: Slot) {
                a.data = b.data;
        }

        static function bar(a: Slot, b: Slot) {
                final data = b.data;
                a.data = data;
        }
}

haxe -lua main.lua -main Main.hx

Main.foo = function(a,b) 
  a.data = _hx_funcToField(b.data); -- <<<<
end
Main.bar = function(a,b) 
  local data = b.data;
  a.data = data;
end

Haxe 4.3.3

@Simn Simn added the platform-lua Everything related to Lua label Nov 26, 2024
@Simn
Copy link
Member

Simn commented Nov 26, 2024

I know nothing about lua but there's indeed some code that generates this for any anon.field = anon.field case. From what I can tell, the _hx_funcToField function is there to deal with situations where we're assigning to a function type at runtime. However, when everything is properly typed like in the case here, I don't see a reason why it would do that.

@jdonaldson Do you happen to remember why it was implemented like that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-lua Everything related to Lua
Projects
None yet
Development

No branches or pull requests

2 participants