Developer Notes

All UFUnctions and UProperties are stored internally in one list that shares the same outer object (the UClass). They have to have different names otherwise the internal hashing of UObjects algorithm would fail.

Description

If the name of a UFUNCTION parameter matches the name of a previously defined UPROPERTY variable, the project will fail compile due to the following reason:

Function parameter: '[Variable/Paramter Name]' conflicts with previously defined field in 'MyActor'

Workaround:
Defining the function before defining the variable allows the code to compile without error.

Steps to Reproduce
  1. Open UE4 Editor (any Project)
  2. Add two classes based on actor (MyActor and MyActor2)
  3. Add the following to MyActor.h
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Test)
    	class AMyActor2* thisVar;
    
    public:
    	UFUNCTION(BlueprintCallable, Category = Test)
    		void AFunctionName(AMyActor2* thisVar);
    
  4. Add the following to MyActor.cpp
    void AMyActor::AFunctionName(AMyActor2* thisVar)
    {
    	this->thisVar = thisVar;
    }
    
  5. Compile

Result:
Compile fails with error message listed in description

Expected:
Parameter name is independent of variable names

Repro Rate:
3/3

Have Comments or More Details?

Head over to the existing Questions & Answers thread and let us know what's up.

0
Login to Vote

Won't Fix
ComponentUE - Foundation - Core
Affects Versions4.10.4
Target Fix4.12
CreatedFeb 29, 2016
ResolvedMar 22, 2016
UpdatedFeb 5, 2017
View Jira Issue