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

Qt.include chokes on deprecated reserved keywords

    XMLWordPrintable

Details

    • Linux/X11
    • 2fa1c92cb7e60f89e200eff48cf7e76d8d2febe6 (qt/qtdeclarative/5.12)

    Description

      When including a JavaScript file from another JavaScript file using Qt.include it fails to register any functions that use reserved keywords that were reserved for future use in ECMAScript 1-3 such as double and char, but are no longer reserved in ECMAScript 5.

      Consider the following main.qml

      import QtQml 2.0
      import "test.js" as Test
      
      QtObject { }
      

      with the following test.js

      Qt.include("someotherfile.js");
      foo("bar");
      

      Now, in someotherfile.js define a function foo which takes an argument named with a "reserved" keyword, such as char

      function foo(char) {
          return true;
      }
      

      Trying to call this function will result in an error

      ReferenceError: foo is not defined

      . If you name theĀ function argument differently, e.g. charr it works fine.

      You also cannot name the function itself char or double or something like this.

      When importing the file from QML directly using import "someotherfile.js" as SomeOtherFile the method can be called just fine via SomeOtherFile.foo("bar"), so this bug only affects Qt.import statement

      Attachments

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

        Activity

          People

            shausman Simon Hausmann
            broulik Kai Uwe Broulik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes