mirror of
https://github.com/microsoft/BCQuality.git
synced 2026-10-07 23:56:56 +01:00
Drop the parentheses from the case false of value sets
Applies NKarolak's review suggestion: a case value set needs no parentheses around a comparison. Encodes the rationale in the Best Practice section, since it is a real advantage of the pattern and is not documented elsewhere in the repo. The AL operator hierarchy places and/xor above the comparison operators and or just above them too, so parentheses are mandatory in an and chain — A = B and C = D misparses without them — while a case value set has no and to bind tighter and needs none. That inverts the precedence most developers arrive with from C#. Also notes in the bad sample that its parentheses are not optional, so the two samples contrast on parentheses as well as on evaluation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
580970ac12
commit
0d5150c47b
3 changed files with 7 additions and 6 deletions
|
|
@ -21,7 +21,8 @@ codeunit 50543 "Perf Sample CaseChain Bad"
|
|||
begin
|
||||
// The wrong escape from the ladder: flattening it into 'and' trades the
|
||||
// nesting for a defect, because every operand is still evaluated. Item
|
||||
// fields are read even when the Get failed.
|
||||
// fields are read even when the Get failed. The parentheses are not
|
||||
// optional either — 'and' binds tighter than '=' and '<>' in AL.
|
||||
exit((SalesLine.Type = SalesLine.Type::Item) and (SalesLine."No." <> '') and
|
||||
(SalesLine."Qty. to Ship" > 0) and Item.Get(SalesLine."No.") and (not Item.Blocked));
|
||||
end;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue