Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule on function prototypes mixed for any/int and ref/non-ref variables #992

Open
FortyTwoFortyTwo opened this issue Oct 30, 2024 · 0 comments

Comments

@FortyTwoFortyTwo
Copy link
Contributor

FortyTwoFortyTwo commented Oct 30, 2024

In 1.11, for function prototypes you're able to mix between any and non-any variables and not able to mix between ref and non-ref, but in 1.12.0.7165 this rule seems to be all over the place on what's allowed and not allowed.

  • No longer able to assign &int param to &any callback, yet still able to assign int param to any callback as normal.
  • Able to mostly mix between ref and non-ref on param and callback

ReturnFunction in this test example are only used to silence unused variable warnings.

typedef CallbackCell = function void (any value);
typedef CallbackRef = function void (any &value);

public void OnPluginStart()
{
	// 4 tests below does not report error in 1.11
	
	CallbackCell cellany = CellAny;	// no error
	ReturnFunction(cellany);
	
	CallbackCell cellint = CellInt;	// no error
	ReturnFunction(cellint);
	
	CallbackRef refany = RefAny;	// no error
	ReturnFunction(refany);
	
	CallbackRef refint = RefInt;	// error
	ReturnFunction(refint);
	
	// 4 tests below does report error in 1.11
	
	CallbackCell badcellany = RefAny;	// no error
	ReturnFunction(badcellany);
	
	CallbackCell badcellint = RefInt;	// no error
	ReturnFunction(badcellint);
	
	CallbackRef badrefany = CellAny;	// no error
	ReturnFunction(badrefany);
	
	CallbackRef badrefint = CellInt;	// error
	ReturnFunction(badrefint);
}

void CellAny(any value) {}
void CellInt(int value) {}
void RefAny(any &value) {}
void RefInt(int &value) {}

Function ReturnFunction(Function func)
{
	return func;
}
@FortyTwoFortyTwo FortyTwoFortyTwo changed the title Rule on Function prototype rule mixed on any/int and ref/non-ref variables Rule on function prototypes mixed on any/int and ref/non-ref variables Oct 30, 2024
@FortyTwoFortyTwo FortyTwoFortyTwo changed the title Rule on function prototypes mixed on any/int and ref/non-ref variables Rule on function prototypes mixed for any/int and ref/non-ref variables Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant