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

Cryptic error message when reserved keyword is used as property name

    XMLWordPrintable

Details

    Description

      While trying to add a "native" property to Menu, I came across an error:

      import QtQuick
      import QtQuick.Controls.Material
      
      ApplicationWindow {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Menu {
              id: menu
              native: true
      
              Action { text: "Cut" }
              Action { text: "Copy" }
              Action { text: "Paste" }
          }
      
          TapHandler {
              onTapped: menu.open()
          }
      }
      
      QQmlApplicationEngine failed to load componentqrc:/main.qml:13:9: Expected token `}'
      

      After reading QTBUG-16062 and consequently https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#keywords, I see that it is a reserved word.

      However, that bug report was closed without any documentation added, and now we simply have this cryptic error message. We should add the list of reserved words to the docs and produce a more useful error message (which could link to the documentation).

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              mitch_curtis Mitch Curtis
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes