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

[REG 5.10 => dev] Integer initialised in for loop is null after loop finishes

    XMLWordPrintable

Details

    • 3967337b61e361c5e9e0209c1810dbc76aabb7bd

    Description

      The following code prints 1 with 5.10, but null with dev:

      import QtQuick 2.5
      import QtQuick.Controls 2.3
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          Component.onCompleted: {
              var str = "ab";
              for (var inputIndex in str) {
                  // ..
              }
      
              print(inputIndex)
          }
      }
      

      The equivalent code in Chrome's console prints 1:

      https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for#Parameters says the following about the initialisation expression:

      These variables are not local to the loop, i.e. they are in the same scope the for loop is in.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            erikv Erik Verbruggen
            mitch_curtis Mitch Curtis
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes