fix(codegen): Initialize UPROPERTY fields in generated Unreal C++ code#3990
Merged
JasonAtClockwork merged 2 commits intoclockworklabs:masterfrom Jan 12, 2026
Merged
Conversation
UE5 strict mode requires all UPROPERTY fields to be explicitly initialized, otherwise the engine logs "property not initialized properly" errors at startup. This change ensures generated reducer/procedure args structs and reducer classes have proper initializers for: - Primitive types (bool, int, float, etc.) - Enum types (PlainEnum) - initialized to first variant The `cpp_ty_init_fmt_impl` function now takes `module` as a parameter to resolve enum type references and generate appropriate default values like `= EMyEnumType::FirstVariant`. Affected generated code: - Reducer args structs (FXxxReducerArgs) - Reducer classes (UXxxReducer) - Procedure args structs (FXxxProcedureArgs) - Product type structs (FXxxType) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
JasonAtClockwork
approved these changes
Jan 12, 2026
Contributor
JasonAtClockwork
left a comment
There was a problem hiding this comment.
Tested and everything looks good to me. Thanks again!
UCLASS(BlueprintType)
class CLIENT_UNREAL_API UTestFunctionReducer : public UReducerBase
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintReadOnly, Category="SpacetimeDB")
int32 X = 0;
UPROPERTY(BlueprintReadOnly, Category="SpacetimeDB")
int32 Y = 0;
UPROPERTY(BlueprintReadOnly, Category="SpacetimeDB")
ETestCType E = ETestCType::Foo;
};
kistz
pushed a commit
to kistz/SpacetimeDB
that referenced
this pull request
Jan 13, 2026
clockworklabs#3990) ## Summary UE5 strict mode requires all UPROPERTY fields to be explicitly initialized, otherwise the engine logs "property not initialized properly" errors at startup. This PR ensures generated Unreal C++ code properly initializes all UPROPERTY fields. ### Changes - Modified `cpp_ty_init_fmt_impl` to accept `module` parameter for enum type resolution - Added initialization for enum types (PlainEnum) using the first variant as default value - Updated all call sites in reducer/procedure/struct generation to pass the module ### Before ```cpp UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB") EMyEnumType SomeEnumField; // ERROR: property not initialized properly ``` ### After ```cpp UPROPERTY(BlueprintReadWrite, Category="SpacetimeDB") EMyEnumType SomeEnumField = EMyEnumType::FirstVariant; // OK ``` ### Affected generated code - Reducer args structs (`FXxxReducerArgs`) - Reducer classes (`UXxxReducer`) - Procedure args structs (`FXxxProcedureArgs`) - Product type structs (`FXxxType`) ## Test plan - [x] Build codegen crate successfully - [x] Generate bindings for a project with enum types - [x] Verify generated code has proper initializers - [x] Build Unreal project without "property not initialized properly" errors --- Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Jason Larabie <jason@clockworklabs.io>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
UE5 strict mode requires all UPROPERTY fields to be explicitly initialized, otherwise the engine logs "property not initialized properly" errors at startup. This PR ensures generated Unreal C++ code properly initializes all UPROPERTY fields.
Changes
cpp_ty_init_fmt_implto acceptmoduleparameter for enum type resolutionBefore
After
Affected generated code
FXxxReducerArgs)UXxxReducer)FXxxProcedureArgs)FXxxType)Test plan
Generated with Claude Code