Replies: 1 comment
-
I like this rule! I would actually go with an error message instead if warning if you pass in a non temp record into a var temp parameter. But I would also add a warning to add handle the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be useful to get a warning if I have a local record that is not temporary, and then I call a function that has the parameter with this record, but set as temporary.
There are a few cases where you deliberately want to go against this rule, but in those few cases a pragma is the way to go (with a justification).
The warning should only be shown if the parameter is "var".
What do you think about this?
Background
When a temporary record parameter is set as "var" (as most often should be for temporary parameters) it does not really matter if you set the parameter as "temporary" or not - The temporary attribute from the record in the calling function will be the one in use. Ie. If the record that is passed in as parameter is not temporary, the parameter will not be temporary - even if the parameter is set as temporary.
So for now we often have
IsTemporary
checks in the function that expects a temporary record, since we cannot be really sure that the calling function has declared it's record as temporary.Having a warning for this would make us discover this issue at build time instead of runtime.
Sample
Procedure declaration:
procedure MyProcedureWithTemporaryRecord(var Item: Record Item temporary)
The call that should trigger a warning:
Beta Was this translation helpful? Give feedback.
All reactions