<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 03.11.2015 17:34, Mattias Gaertner
wrote:<br>
</div>
<blockquote cite="mid:20151103173446.7ddce1fa@limapholos.matflo.wg"
type="cite">
<pre wrap="">codetools use only a simple heuristic to calculate the type of a
binary operator.
The function TFindDeclarationTool.CalculateBinaryOperator needs to be
extended for Alias types (e.g. 'integer' instead of longint) and for
ranges (e.g. if the operands do not fit into an integer).
</pre>
</blockquote>
<br>
Maybe you are talking about the same, but just to be sure: IMO using
hard-coded alias types is not a good idea (theoretically the user
can redefine them). Instead the type evaluation should go to the end
type (e.g. from Integer to <b>longint</b>) and then the end types
should be compared. The comparison can then be done with a
hard-coded table (you need it only for the basic types, so it is OK
and safe) and the type that wins, will be used as the result type
(obviously the originally used alias).<br>
<br>
E.g.:<br>
<br>
procedure Test;<br>
var<br>
I: Integer;<br>
S: SmallInt;<br>
begin<br>
Res := I + S;<br>
end;<br>
<br>
Something like:<br>
1.)<br>
I = (Integer -> longint)<br>
S = SmallInt<br>
2.)<br>
ResultBasicType = Compare(longint, SmallInt) -> longint -> I<br>
3.)<br>
ResultType = ResultBasicType -> I -> <b>Integer</b><br>
<br>
Reported:<br>
<a class="moz-txt-link-freetext" href="http://mantis.freepascal.org/view.php?id=28953">http://mantis.freepascal.org/view.php?id=28953</a><br>
<br>
Ondrej<br>
</body>
</html>