You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This should be a new rule, not an improvement to an existing rule.
This rule would be generally useful, not specific to my code or setup.
Suggested rule title
VarArgumentsShouldBeInitialized
Rule description
In #127, there was a discussion on whether var argument should be considered as initializing a variable. Although out arguments should be preferred for that, a confusion in the Delphi compiler (out and var are processed similarly) has lead some teams to accept initialization through var. So, this was suggested as a new rule rather than an improvement or the rule that "variables should be initialized before being used".
This rule states that a variable is "used" when passed as a var argument to a function call, so doing so without the variable being initialized should be warned against.
Rationale
If you do not accept in your code base that initialization could be done via a var argument, then the rationale is the same as stating that a variable should be initialized before being used.
It is especially important for record variables, for which the Delphi compiler does not enforce this basic rule!
The text was updated successfully, but these errors were encountered:
Cirras
changed the title
VAR arguments should be initialized before the call
New rule: var arguments should be initialized before the call
Dec 19, 2023
Prerequisites
Suggested rule title
VarArgumentsShouldBeInitialized
Rule description
In #127, there was a discussion on whether
var
argument should be considered as initializing a variable. Althoughout
arguments should be preferred for that, a confusion in the Delphi compiler (out
andvar
are processed similarly) has lead some teams to accept initialization throughvar
. So, this was suggested as a new rule rather than an improvement or the rule that "variables should be initialized before being used".This rule states that a variable is "used" when passed as a
var
argument to a function call, so doing so without the variable being initialized should be warned against.Rationale
If you do not accept in your code base that initialization could be done via a
var
argument, then the rationale is the same as stating that a variable should be initialized before being used.It is especially important for record variables, for which the Delphi compiler does not enforce this basic rule!
The text was updated successfully, but these errors were encountered: