Constants resulting in Infinity not working
Original Reporter info from Mantis: wlandgraf
-
Reporter name: Wagner Landgraf
Original Reporter info from Mantis: wlandgraf
- Reporter name: Wagner Landgraf
Description:
The following program fails to execute:
---
program TestPas2JSInfinity;
{$APPTYPE CONSOLE}
uses
SysUtils, Math;
const
INF2 = 1.0 / 0.0;
begin
if INF2 = Infinity then
WriteLn('Is inifinite')
else
WriteLn('not infinite');
end.
---
In Delphi, 1.0 / 0.0 is a valid const that results as infinity at compile-time.
Even if Pas2JS don't want to comply by design, at least some better error message should be provided. Currently the error is:
Uncaught ReferenceError: Inf is not defined
at Object.$mod.$main (TestPas2JSStream.dpr:14)
at Object.run (rtl.js:141)
at index.html:19
Due to the following JavaScript being generated:
this.INF2 = 1.0 / 0.0;
$mod.$main = function () {
if ( +Inf === Infinity) {
pas.System.Writeln("Is inifinite")}
else pas.System.Writeln("not infinite");
};
Mantis conversion info:
- Mantis ID: 38815
- Fixed in revision: 49370.