On Tue, 3 Nov 2015 20:34:30 +0100 Ondrej Pokorny <[email protected]> wrote:
> On 03.11.2015 20:26, Mattias Gaertner wrote: > >> procedure Test; > >> >var > >> > I: Integer; > >> > S: SmallInt; > >> >begin > >> > Res := I + S; > >> >end; > >> > > >> >Something like: > >> >1.) > >> >I = (Integer -> longint) > >> >S = SmallInt > >> >2.) > >> >ResultBasicType = Compare(longint, SmallInt) -> longint -> I > >> >3.) > >> >ResultType = ResultBasicType -> I ->*Integer* > > That would fail with the following example: > > > > var > > i: SizeInt; > > j: SmallInt; > > begin > > k:=i+j; > > end; > > > > The result should be SizeInt, not Integer. > > No, the result will be SizeInt, because (SizeInt -> LongInt) wins over > SmallInt and the result thus will be SizeInt (as the original type alias > of /*i*/) and not Integer. Good. > A problem could be with such code: > > var > i: SizeInt; > j: Integer; > begin > k:=i+j; > end; > > Because obviously on 32bit SizeInt=longint and Integer=longint, so there > won't be a deterministic way which type wins. Left side wins. It can't be perfect, but it should be deterministic. Mattias -- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
