FR: Exclude assigned variables, referenced variables and parameters in global/local variable warning Topic is solved

Propose new features and changes
User avatar
RUBn
Posts: 51
Joined: 27 Nov 2013, 05:12
Contact:

FR: Exclude assigned variables, referenced variables and parameters in global/local variable warning

09 Nov 2023, 04:01

This is a feature request around evading global variables and local variables, but when it's not necessary to warn about possible confusion as stated in the doc.

So OK, the doc.says Global Variables: However, if a variable is used in an assignment or with the reference operator (&), it is automatically local by default.
It's the same for function parameters. It doesn't say in the doc, but I tested it.

So, what I do NOT do is using special naming of local variables and function parameters such as L_var. I just make sure one of the above conditions are true, The thing is #Warn All still warns about it.
But since I noticed from other errors that the "code checker" that outputs these warnings, DOES check for assignments and these conditions, I propose #Warn All stops warning about possible local variables mix-up when the above conditions are true.

This idea started in this topic post.

I am also: Image-motiv for professional, volunteer & open source (web) development
lexikos
Posts: 9665
Joined: 30 Sep 2013, 04:07
Contact:

Re: FR: Exclude assigned variables, referenced variables and parameters in global/local variable warning  Topic is solved

16 Nov 2023, 20:52

Unless I'm missing something, what you want is the default behaviour. Either don't use #Warn All, or use #Warn LocalSameAsGlobal, Off after it. #Warn VarUnset covers the cases where a variable is not assigned or used with the reference operator.

If what you want differs in some way to the default behaviour, please demonstrate with code.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 7 guests