Repository navigation
fix(PC0038): treat member initialization of named record returns as assignment - #598
Open
MODUSCarstenScholling wants to merge 2 commits into
Open
MODUSCarstenScholling wants to merge 2 commits into
MODUSCarstenScholling wants to merge 2 commits into
Conversation
…ssignment - Fixes ALCops#596 - Count field and property assignments on the named return (Result."No." := ..., Result.ReadIsolation := ...) as initialization - Unwrap conversions around the receiver and var arguments, so temporary records passed to a non-temporary var Record parameter and Clear(Result) count - Accept Init() and Clear() as explicit initialization, even as the only statement - Add NoDiagnostic fixtures for field, property, view-state, var-argument, Init and Clear forms; pin the empty body as HasDiagnostic - Document design decisions and runtime facts in the rule doc and regression catalog
…s initialization - Unwrap conversions around var arguments, so temporary records passed to a non-temporary var Record parameter and Clear(Result) count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PC0038 reported named
Recordreturn values withoutexit(...)as "not all code paths return a value", although the procedure had initialized the return variable through its fields. For records the named form is the idiomatic one:exit(LocalRecord)is a record assignment that drops filters, the current key and the rows of a temporary table.Fixes #596
Changes
Result."No." := No;) counts as assignment.vararguments are unwrapped before matching the named return. This covers a temporary record passed to a non-temporaryvar Recordparameter, andClear(Result).Init()andClear()count as explicit initialization, even as the only statement. An empty body is still reported.Tests
NoDiagnosticfixtures:Clear()(alone and followed by a field assignment), and the non-temporaryvarargument.ReadIsolation,Init(), the temporaryvarargument, and field assignment followed byInsert().HasDiagnosticfixture: empty body.netstandard2.1,net8.0andnet10.0succeeds;dotnet formatis clean.Docs: ALCops/alcops.dev (PR #215).