vscode-rpgle
vscode-rpgle copied to clipboard
Lint Option: Input parameters not changed within a procedure should be specified with CONST
Been thinking about this. Quite a lot to think about. One case I can think would be tricky is if a parameter gets passed into another procedure, and it's passed by reference and changed inside of it.
I think you have to assume that if its not passed as a constant in the PI then it will be changed in the underlying procedure. This is fine though as Eventually you will get to the bottom of the stack and where the variable is not changed it will suggest it to be a CONST... then the procedure above will do the same... until we get back to the top level
i.e. if a variable can be changed assume it will be changed
Yup that makes sense! Unless the linter has the prototype and then we can tell if it's ref/const/value!
Yeah although the PI/PR have to be aligned right?
Ignore that I see what you are saying, yeah I think you need to look at the prototype for the called procedure, failing that you will need to look at the interface if its in the same source and a prototype is not declared
Thinking about it, I think we also need to hope no one actually uses overloading!! Because then you have to match a signature of the call to one of the overloaded procedures (I'm not entirely sure what the rules are for this as I've never actually used it!)
Edit
Looks like Scott Klement has kindly put a presentation together for this: https://www.scottklement.com/presentations/Overloading%20Subprocedures%20in%20RPG.pdf
Although I do wonder if you hit an overload statement in the PR then just say it's a modification to the variable, and come back to it if anyone requests it!
Good share - forgot about that completely!