Page MenuHomeFeedback Tracker

Can't find matching overload for function Error
Closed, ResolvedPublic

Description

I got a few messages from people running my mods and running into the issue, that adding y mods would cause a compile error, which only happens when certain other mods are loaded.
From my experiments, I found the cause for the error and it seems to be an engine bug
The problem is, that when having a function taking a Class as input and have other methods overloading it, you might trigger the error when calling the method with an instance of a class, which has been Modded around 150 times and sometimes even less. (It also only seems to affect classes from the vanialla scripts and no classes added via new scripts)

When using the script below, you will receive the following error when trying to start the Server with the scripts loaded:

---------------------------------------------
Log C:\Program Files (x86)\Steam\steamapps\common\DayZServer\profiles\script_2023-11-09_16-45-33.log started at 09.11. 16:45:34

SCRIPT       : Registered 299 temporary action enum(s), UAN==299
SCRIPT    (E): @"BreakingScriptCollection/Scripts/3_Game/cause.c,11": Can't find matching overload for function 'PrintMe'
SCRIPT    (E): @"BreakingScriptCollection/Scripts/3_Game/cause.c,17": Can't find matching overload for function 'PrintMe'
SCRIPT    (W): @"BreakingScriptCollection/Scripts/3_Game/cause.c,34": No need to use 'Cast' for up-casting
SCRIPT    (E): Can't compile "Game" script module!

BreakingScriptCollection/Scripts/3_Game/cause.c(11): Can't find matching overload for function 'PrintMe'
SCRIPT    (E): Failed to load game scripts!

Details

Severity
Crash
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Category
General
Steps To Reproduce

write two scripts inside the 3_Game module. For 4_World, replace the DayZGame with ItemBase or for 5_Mission replace DayZGame with MissionServer.

write a script with around 200 lines repeatingly modding the DayZGame class like this modded class DayZGame {}
and have another script like this:

void PrintMe(string str) {
	Print(str);
}

void PrintMe(Class instance) {
	Print(instance.ToString());
}
// One way of triggering the error (the method call does not have to be in the modded class)
void TriggerError() {
	DayZGame instance = new DayZGame();
	PrintMe(instance);
}
// Another way of triggering the error with calling PrintMe with this
modded class DayZGame {
	
	void DayZGame() {
		PrintMe(this);
	}
	
}
// Workaround to not trigger the error would be to do an indirect cast to Class and assign it to a variable
modded class DayZGame {
	
	void DayZGame() {
		Class instance = this;
		PrintMe(instance);
	}
	
}
// Workaround to not trigger the error would be to do a direct cast to Class and assign it to a variable
modded class DayZGame {
	
	void DayZGame() {
		PrintMe(Class.Cast(this));
	}
	
}
Additional Information

Related Objects

Duplicates Merged Here
T178085: GetDebugName

Event Timeline

LBmaster created this task.Nov 9 2023, 4:47 PM

The mdmp is from a 1.22.156718 Server, but it also happens on the latest version and has been a problem in older versions too

LBmaster added a subscriber: Geez.Nov 14 2023, 10:12 AM

@Geez please have a look at this

Geez changed the task status from New to Assigned.Nov 20 2023, 12:24 PM
lava76 added a subscriber: lava76.Nov 30 2023, 10:59 PM
NATION added a subscriber: NATION.Dec 1 2023, 12:17 AM
polpa added a subscriber: polpa.Dec 1 2023, 12:29 AM
Choze added a subscriber: Choze.Dec 1 2023, 12:58 AM

When will this issue be resolved?

Axe0_0 added a subscriber: Axe0_0.Dec 1 2023, 10:19 AM
ARSENIC added a subscriber: ARSENIC.Dec 1 2023, 4:06 PM
Urs0815 added a subscriber: Urs0815.Dec 1 2023, 7:18 PM
Senfo added a subscriber: Senfo.Dec 3 2023, 4:12 PM
Gr1m_69 added a subscriber: Gr1m_69.Dec 4 2023, 9:20 PM
Half added a subscriber: Half.Dec 6 2023, 2:52 PM
Mars22 added a subscriber: Mars22.Dec 29 2023, 4:22 PM
Kreser added a subscriber: Kreser.Dec 31 2023, 3:05 PM

please fix too many mods stop working

Geez closed this task as Resolved.Jan 2 2024, 10:36 AM
Geez claimed this task.

Hello everyone.
We have fixed the problem on our end and the fix should be released with the 1.24 update.

Would you be able to have one of the team members provide a brief technical summary of the issue and its resolution? Out of all the bugs I've seen in enforce script, this is by far one of the most peculiar, inconsistent one to date.

Geez added a comment.Jan 16 2024, 2:11 PM

Would you be able to have one of the team members provide a brief technical summary of the issue and its resolution? Out of all the bugs I've seen in enforce script, this is by far one of the most peculiar, inconsistent one to date.

Straight from the dev team ;)

When the compiler is looking for a matching overload, it is internally using a score system.
In the case there is a class with inheritance, it will traverse the tree and increment for every super.
It used to check against a hardcoded value of 100, and when exceeding this value, it would be seen as non-matching by default.
When modding a class, this is treated as if one is inheriting from it, so when a class was modded 100+ times, it would exceed the hardcoded value >and be unable to find a "matching" overload.
Additionally, this score is summed for each input parameter, so it could also be reproduced by having a method with for example two parameters >where both of them had a class which was modded 50+ times.

A secondary issue with this score calculation was also that when filling in 'null' as value, it would be given a score of 100.
Which made it impossible, when keeping in mind the previous mention of summing the scores for each parameter, to call an overloaded method with >for example "SomeMethod(null, null);" as it would reach a score of 200.

The resolution was to refactor this score calculation to not use a hardcoded value of 100, it is now using UINT_MAX, which moves the max inheritance >sum of parameters for overloaded functions from 100 to 4294967295.

Thanks for the detailed answer (and resolution of course) :-)

I just checked if my 1.24 Experimental Server and it does not start with the PBO loaded and I still get the same error. Has the fix not been merged into the first Experimental Build? I also haven't seen it in the 1.24 changelog in the forums.

I hope they will fix this by the stable release 1.24 because I can’t add some mods to myself because there’s a conflict

Nice. Seems to be fixed with the last 1.24.157353 update