Skip to content

Conversation

@jdonaldson
Copy link
Member

Summary

Fixes #11842. Non-function fields were being unnecessarily wrapped with _hx_funcToField during assignment.

Problem

When assigning fields between anonymous types (typedefs), the Lua generator wrapped all assignments with _hx_funcToField, even for non-function types like Int:

typedef Slot = { var data: Int; }

// This generated: a.data = _hx_funcToField(b.data)
a.data = b.data;

Fix

Added is_function_type e2.etype guards to three patterns in genlua.ml that were missing them. The fourth pattern (for TLocal assignments) already had this check.

Test plan

  • Added unit test testNoFuncToFieldForNonFunctions in TestLua.hx
  • All 11520 Lua unit tests pass

Fixes HaxeFoundation#11842. The OpAssign patterns in genlua.ml were wrapping all
field assignments between anonymous/closure types with _hx_funcToField,
regardless of whether the field was actually a function type.

Added is_function_type checks to the three patterns that were missing
them, matching the existing pattern for TLocal assignments.
@Simn Simn merged commit 3aed86e into HaxeFoundation:development Jan 5, 2026
49 checks passed
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.

Redundant call _hx_funcToField for lua target

2 participants