Page MenuHomeFeedback Tracker

Script compiler bug - Ambiguous function call 'Equals' - except its not ambiguous at all?
Closed, ResolvedPublic

Description

The code below should compile and work, but it does not. I am not sure why. I tried to play around but so far I could only identify that this bug happens if the two function overloads are in the form name + nameSuffixed. Best to debug the compiler to see what exactly is going on there. Trial and error lead me nowhere sadly. This only seemed to happen if I have a number convertible type as an overload (int, float, bool). String does not trigger the problem. Different function name variants or different parameters seem to indicate that functions are being confused by the end of their name? s. Comments below on this issue for more examples.

class OMG_HOW_DID_THIS_HAPPEN
{
	void Equals(int comparisonValue) 
	{
	}
	
	void Equals(float comparisonValue) 
	{
	}
	
	void LessThanOrEquals(int comparisonValue)
	{
	}
	
	void LessThanOrEquals(float comparisonValue)
	{
	}
}

void Bruh()
{
	OMG_HOW_DID_THIS_HAPPEN inst();
	inst.Equals(42.323);
}

SCRIPT (E): @"Scripts/Game/test.c,23": Ambiguous function call 'Equals', candidates:
SCRIPT (E): @"Scripts/Game/test.c,23": Equals(float)
SCRIPT (E): @"Scripts/Game/test.c,23": Equals(float)
SCRIPT (E): @"Scripts/Game/test.c,23": Can't find matching overload for function 'Equals'
SCRIPT (E): Can't compile "Game" script module!

Scripts/Game/test.c(23): Ambiguous function call 'Equals', candidates:

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce
  1. Create a new file test.c in Scripts/Game
  2. Paste code of the example
  3. Try to compile
  4. Be as confused as I am

Event Timeline

Arkensor created this task.Jul 25 2022, 9:14 PM

In this case, you can see that the compiler considers EqualsBruh and LessThanOrEqualsBruh the same name after compilation? I think that might be part of the error? This should not normally happen?

function(float,int) can only be the void LessThanOrEqualsBruh(float comparisonValue, int dummyVal = 1) and function(float,bool) can only be void EqualsBruh(float comparisonValue, bool dummyVal = false). None of the overloads are the same. So I am very confused about what is going on.

class OMG_HOW_DID_THIS_HAPPEN
{
	void EqualsBruh(int comparisonValue, vector dummyVal = "0 0 0") 
	{
	}
	
	void EqualsBruh(float comparisonValue, bool dummyVal = false) 
	{
	}
	
	void LessThanOrEqualsBruh(int comparisonValue, string dummyVal = "hi")
	{
	}
	
	void LessThanOrEqualsBruh(float comparisonValue, int dummyVal = 1)
	{
	}
}

void Bruh()
{
	OMG_HOW_DID_THIS_HAPPEN inst();
	inst.EqualsBruh(42.323);
}

SCRIPT (E): @"Scripts/Game/test.c,23": Ambiguous function call 'EqualsBruh', candidates:
SCRIPT (E): @"Scripts/Game/test.c,23": EqualsBruh(float,bool)
SCRIPT (E): @"Scripts/Game/test.c,23": EqualsBruh(float,int)
SCRIPT (E): @"Scripts/Game/test.c,23": Can't find matching overload for function 'EqualsBruh'
SCRIPT (E): Can't compile "Game" script module!

Scripts/Game/test.c(23): Ambiguous function call 'EqualsBruh', candidates:

It also happens with other names, it is not exclusive to just "Equal" or "Equals".

class OMG_HOW_DID_THIS_HAPPEN
{
	void Bruh(int comparisonValue, vector dummyVal = "0 0 0") 
	{
	}
	
	void Bruh(float comparisonValue, bool dummyVal = false) 
	{
	}
	
	void PrefixBruh(int comparisonValue, string dummyVal = "hi")
	{
	}
	
	void PrefixBruh(float comparisonValue, int dummyVal = 1)
	{
	}
}

void Bruh()
{
	OMG_HOW_DID_THIS_HAPPEN inst();
	inst.Bruh(42.323);
}
Arkensor updated the task description. (Show Details)Jul 26 2022, 9:27 AM
MarioE added a subscriber: MarioE.Jul 26 2022, 9:40 AM

Tested some other cases and also found that :

void 123Bruh(float comparisonValue, string dummyVal = "hi")

Throws an error andd with some extra Testing any function name with numbers at the start causes errors, numbers in between are fine.

Also can further verify that the main issue is not linked to any specific combination of "dummyVal" types (custom types can also create this error, so the direct conversion from one type to another is not needed to cause this error)

Geez changed the task status from New to Assigned.Aug 8 2022, 10:59 PM
Arkensor added a subscriber: Geez.Oct 1 2022, 2:58 PM

@Geez this issue is now fixed as of 0.9.6 exp patch.

Geez closed this task as Resolved.Oct 6 2022, 2:23 PM
Geez claimed this task.