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

v4: when function argument name matches a local variable name, local variable is marked undefined

    XMLWordPrintable

Details

    • 2e8dfb5d5cd02cf2ca281f19bfb9966c97f35db7

    Description

      Try this snippit with Qt5.2 beta1, then compare with Qt5.0:

      import QtQuick 2.0
      
      MouseArea {
          width: 200
          height: 100
      
          QtObject {
              id: d
              function hello(input) {
                  var temp = "Hello " + input;
                  var input = temp + "!";
                  print(input);
              }
          }
      
          onClicked: {
              d.hello("you")
          }
      }
      

      In 5.0, it prints "Hello you!" but in 5.2 it prints "Hello undefined!"

      The fact that the function 'hello' names its argument the same as one of its local variables is naughty, but I suspect it should work. I'm no EMCAScript master however.

      Attachments

        Issue Links

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

          Activity

            People

              erikv Erik Verbruggen
              gerboland Gerry Boland
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes