mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:19:12 +02:00
codetools: ignore constant operand in operator comparison if the other operand has a defined type.
git-svn-id: trunk@50230 -
This commit is contained in:
parent
9271bc1893
commit
1b015d1034
@ -1485,11 +1485,20 @@ function TTypeAliasOrderList.Compare(const Operand1,
|
||||
var
|
||||
xCompRes: Integer;
|
||||
begin
|
||||
//first compare base types
|
||||
// first check if one of the operands is a constant -> if yes, automatically
|
||||
// return the other
|
||||
// (x := f + 1; should return always type of f)
|
||||
if (Operand1.Expr.Desc in xtAllConstTypes) and not (Operand2.Expr.Desc in xtAllConstTypes) then
|
||||
Exit(Operand2)
|
||||
else
|
||||
if (Operand2.Expr.Desc in xtAllConstTypes) and not (Operand1.Expr.Desc in xtAllConstTypes) then
|
||||
Exit(Operand1);
|
||||
|
||||
// then compare base types
|
||||
xCompRes := Compare(
|
||||
Tool.FindExprTypeAsString(Operand1.Expr, CleanPos, nil),
|
||||
Tool.FindExprTypeAsString(Operand2.Expr, CleanPos, nil));
|
||||
//if base types are same, compare aliases
|
||||
// if base types are same, compare aliases
|
||||
if xCompRes = 0 then
|
||||
xCompRes := Compare(
|
||||
Tool.FindExprTypeAsString(Operand1.Expr, CleanPos, @Operand1.AliasType),
|
||||
|
Loading…
Reference in New Issue
Block a user