If I add a new operator and mix up the definition for TOperators, DelphiAST will not complain.
A simple fix solves this issue, forcing the two structures to be in sync.
const
OperatorsInfo: array [ntAddr..ntIs] of TOperatorInfo = //1: use A TSyntaxNodeType as the index.
((Typ: ntAddr; Priority: 1; Kind: okUnary; AssocType: atRight),
(Typ: ntDoubleAddr; Priority: 1; Kind: okUnary; AssocType: atRight),
(Typ: ntDeref; Priority: 1; Kind: okUnary; AssocType: atLeft),
...
class function TOperators.GetItem(Typ: TSyntaxNodeType): TOperatorInfo;
begin
Assert(Typ = OperatorsInfo[Typ].Typ); //2: force the Typ's to match.
if (Typ in [ntAddr..ntIs]) then Exit(OperatorsInfo[Typ])
else Assert(false); //do not allow buffer overruns.
end;
If I add a new operator and mix up the definition for
TOperators
, DelphiAST will not complain.A simple fix solves this issue, forcing the two structures to be in sync.