Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-111179

Incorrect coercion to number for undefined

    XMLWordPrintable

Details

    • b9834e0ee (dev), ecf96e338 (6.5), c7e6eeccd (tqtc/lts-6.2), 4f7cda0c9 (6.4), d015bb83e (tqtc/lts-6.2)

    Description

      When the javascript in the undefined.qml file is compiled and executed, the call to Math.max() returns 40 whereas it should return NaN. 

      AFAIK, this is due to the fact that the undefined value is handled as a 0.0 double instead of being coerced into a NaN as expected (mdn) as can be seen in the generated C++ code: 

      // generate_LoadUndefined
      r2_1 = 0.0;

       

      Replacing "Math.max(undefined, 40)" with "Math.max(Number(undefined), 40)" or "Math.max(new Number(undefined), 40)"correctly performs the coercion to NaN.

      Attachments

        1. undefined.qml
          0.2 kB
          Olivier De Cannière

        Activity

          People

            ulherman Ulf Hermann
            olivier.decanniere Olivier De Cannière
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: