Skip to content

docs(PC0038): explain named record return initialization and what reaches the caller - #215

Open
MODUSCarstenScholling wants to merge 2 commits into
ALCops:mainfrom
MODUSCarstenScholling:dev-cs-issue596-pc0038-falsepos
Open

MODUSCarstenScholling wants to merge 2 commits into
ALCops:mainfrom
MODUSCarstenScholling:dev-cs-issue596-pc0038-falsepos

Conversation

@MODUSCarstenScholling

Copy link
Copy Markdown
Contributor

Summary

Documents how PC0038 treats named Record return values, and what a returned record actually carries to the caller. Companion to ALCops/Analyzers#598 (fixes ALCops/Analyzers#596).

Changes

  • Field assignments, filters and keys set on a named Record return count as assigned.
  • Init() and Clear() count as well. Both apply the InitValue defaults; only Init() keeps the primary key, filters and key.
  • New section "What a returned record carries to the caller":
    • Filters and key survive only when the call result is used directly.
    • exit(LocalRecord) and a caller-side assignment copy field values only.
    • CopyFilters() and Copy() on a call result do not compile (AL0130).
    • To hand state to the caller, use a var parameter or GetView()/SetView().
  • Links to Microsoft Learn (AL complex types) and waldo's article on complex return types.

…ches the caller

- Implements #596
- Document that field assignments, filters and keys set on a named Record return count as assigned
- Document that Init() and Clear() count as well, and how they differ (InitValue defaults versus primary key, filters and key)
- Add a section on what a returned record carries to the caller: filters and key survive only direct use, while exit(LocalRecord) and caller-side assignments copy field values only
- Note that CopyFilters()/Copy() on a call result do not compile (AL0130) and recommend var parameters or GetView()/SetView()
- Link the Microsoft Learn article on AL complex types

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Rule PC0038 throws warning on named record return variables

1 participant