Is this a bug: static UFUNCTION shadowing is not allowed

Here’s the code:

UCLASS(BlueprintType)
class TESTS_API UVectorProperty : public UVectorBaseProperty
{
	GENERATED_BODY()

public:

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VectorProperty")
	FVector Location;

	UFUNCTION(BlueprintPure, Category = "VectorProperty", Meta = (CompactNodeTitle = "Vector", DisplayName = "Create Vector Property", HidePin = "Property"))
	static UVectorProperty* Create(FVector Location, UVectorProperty* Property = nullptr);

	UFUNCTION(BlueprintPure, Category = "VectorProperty")
	virtual FVector GetValue() const override { return Location; };
};

and here’s the error:

2>    Running UnrealHeaderTool "E:\Unreal Projects\Tests\Tests.uproject" "E:\Unreal Projects\Tests\Intermediate\Build\Win64\TestsEditor\Development\UnrealHeaderTool.manifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors -installed
2>  E:/Unreal Projects/Tests/Source/Tests/Debug/DebugVisualiserProperties.h(46) : Function parameter: 'Location' cannot be defined in 'Create' as it is already defined in scope 'VectorProperty' (shadowing is not allowed)

If I understand this correctly, it seems like the compiler won’t allow this because it thinks that the FVector Location parameter will hide the Location member.
Correct me if I’m wrong, but seeing as Create is static and Location is not, the two of them cannot clash in any way.

Have you solve it?

Renaming it may solve this.

Not sure if it is a bug that UE4’s own compiler regards some words as keywords.

Your variables are the same. In

FVector Location;

and

static UVectorProperty* Create(FVector Location, UVectorProperty* Property = nullptr);

How do you expect the compiler know which one you want in

void UVectorProperty::Create(FVector Location)
{
    // Which one you want here? THe function Location ?
    // or this->Location?
    // Both can be called with the variable "Location"
}
3 Likes

It’s the static function. It doesn’t have this.

This bug still exists in 5.1.

2 Likes