โŒ About FreshRSS

Normal view

There are new articles available, click to refresh the page.
Before yesterdayNews from the Ada programming language world

Type conversions and if expressions

In this page, John Barnes writes:

If the conditional expression is the argument of a type conversion then effectively the conversion is considered pushed down to the dependent expressions. Thus

X := Float(if P then A else B);

is equivalent to

X := (if P then Float(A) else Float(B));

So why can't I compile the following program under GNAT 10.3.0?

procedure Main is
   P : Boolean := True;
   X : Float;
begin
   X := Float (if P then 0.5 else 32);
end Main;
Compile
   [Ada]          main.adb
main.adb:5:35: expected a real type
main.adb:5:35: found type universal integer
gprbuild: *** compilation phase failed
โŒ
โŒ