Page MenuHomeFeedback Tracker

Ref in Generic not working
Assigned, UrgentPublic

Description

When using a ref for generics, which are not of the Type array or map, it does not work properly.
I added a small piece of Code to show what the problem is

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
General
Steps To Reproduce
modded class MissionServer {

	Param1<ref RefTestClass> GetError() {
		Param1<ref RefTestClass> found = new Param1<ref RefTestClass>(new RefTestClass());
		return found;
	}

	array<RefTestClass> GetError2() {
		array<RefTestClass> found = new array<RefTestClass>();
		found.Insert(new RefTestClass());
		return found;
	}

	Param1Ref<RefTestClass> GetWorking() {
		Param1Ref<RefTestClass> found = new Param1Ref<RefTestClass>(new RefTestClass());
		return found;
	}

	array<ref RefTestClass> GetWorking2() {
		array<ref RefTestClass> found = new array<ref RefTestClass>();
		found.Insert(new RefTestClass());
		return found;
	}
	
	void MissionServer() {
		Param1<ref RefTestClass> found1 = GetError();
		Print("Finished loading entry 1");
		Print(found1.param1); // Null even though ref was used
		
		array<RefTestClass> found2 = GetError2();
		Print("Finished loading entry 2");
		Print(found2.Get(0)); // Null as expected
		
		Param1Ref<RefTestClass> found3 = GetWorking();
		Print("Finished loading entry 3");
		Print(found3.param1); // Working fine when ref is on the variable declaration of the generic ("ref T1 param1;" instead of "T1 param1;")
		
		array<ref RefTestClass> found4 = GetWorking2();
		Print("Finished loading entry 4");
		Print(found4.Get(0)); // Working as expected with ref in array generic
		
	}
	
}
class RefTestClass {
}

class Param1Ref<Class T1> {

	ref T1 param1;
	
	void Param1Ref(T1 param1_) {
		this.param1 = param1_;
	}
	
}

Event Timeline

LBmaster created this task.Apr 3 2023, 2:42 PM
LBmaster edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Apr 4 2023, 10:20 AM
lava76 added a subscriber: lava76.Apr 19 2023, 10:41 PM