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

QJSEngine doesn't recognize "import" statements...

    XMLWordPrintable

Details

    • Windows

    Description

      The following program, which is given as the actual example from when `registerModule` was added (https://codereview.qt-project.org/c/qt/qtdeclarative/+/345339):
       

          QJSEngine engine;
      
          QJSValue num(666);
          engine.registerModule("themarkofthebeast", num);
      
          QString program = "import badnews from \"themarkofthebeast\";";
          QJSValue result = engine.evaluate(program);
      
          qDebug() << result.toString(); 

      Fails to execute, producing the following output on the console:

      "SyntaxError: Unexpected token `import'"

      In other words, QJEngine appears to not understand "import" at all, which is weird because it's literally the example given in the patch that added registerModule to QJSEngine.

      As a consequence:

      • registerModule can't be used for anything
      • no modules can be imported in the JS program
      • it is prohibitively difficult to extend the JS with C++ code

      Unless I'm making some sort of usage mistake, this seems both basic and severe, and I'm not sure how registerModule would have ever passed testing to begin with...

      Attachments

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

        Activity

          People

            amanda.hamblin-true Amanda Hamblin-True (Inactive)
            jasonc Jason Cipriani
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes