View Issue Details

IDProjectCategoryView StatusLast Update
0038815pas2jstranspilerpublic2021-05-15 12:10
ReporterWagner Landgraf Assigned ToMattias Gaertner  
Status resolvedResolutionfixed 
Summary0038815: Constants resulting in Infinity not working
DescriptionThe following program fails to execute:

program TestPas2JSInfinity;


  SysUtils, Math;

  INF2 = 1.0 / 0.0;
    if INF2 = Infinity then
      WriteLn('Is inifinite')
      WriteLn('not infinite');

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 (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");

TagsNo tags attached.
Fixed in Revision49370.
Attached Files


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2021-04-27 22:07 Wagner Landgraf New Issue
2021-04-27 22:20 Mattias Gaertner Assigned To => Mattias Gaertner
2021-04-27 22:20 Mattias Gaertner Status new => assigned
2021-05-15 12:10 Mattias Gaertner Status assigned => resolved
2021-05-15 12:10 Mattias Gaertner Resolution open => fixed
2021-05-15 12:10 Mattias Gaertner Fixed in Revision => 49370.