-
Notifications
You must be signed in to change notification settings - Fork 66
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
Comments
|
1.11 does correctly report these four as not matching, but 1.12 gives a different result, where it now errors at line 17 and no errors on line 22, 25, and 28. This makes it that
|
Thanks, my eyes glazed over on the first look. I've fixed the lack of errors which was definitely a serious bug. Re: any& coercing to int&... I'm on the fence. I don't love it, but it's not really unsafe. If it's something legitimately useful to a lot of plugins, I'll consider it. |
Allowing this coercion affected 0 plugins in the corpus... |
In non-ref coercing is very helpful for functions like |
Do you have a testcase for non-ref coercing that doesn't work? |
I think non-ref coercing all works fine for both 1.11 and 1.12, able to use typedef CallbackCell = function void (any value);
typedef CallbackRef = function void (any &value);
public void OnPluginStart()
{
// coercing 'int' param to 'any' callback, works fine
CallbackCell cellint = CellInt;
ReturnFunction(cellint);
// coercing 'int&' param to 'any&' callback, function prototypes do not match
CallbackRef refint = RefInt;
ReturnFunction(refint);
}
void CellInt(int value) {}
void RefInt(int &value) {}
Function ReturnFunction(Function func)
{
return func;
}
|
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 in1.12.0.7165
this rule seems to be all over the place on what's allowed and not allowed.&int
param to&any
callback, yet still able to assignint
param toany
callback as normal.ReturnFunction
in this test example are only used to silence unused variable warnings.The text was updated successfully, but these errors were encountered: