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

[QML] Default parameters with type annotations not supported

    XMLWordPrintable

Details

    • All

    Description

       Having code like 

      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          function grumble(info, popup = true) {
              console.log(info, popup)
          }
      }
      

      and 

      Item {
          function wohoooo(info : string, popup : bool = true) {
              console.log(info, popup)
          }
      }
      

      runs into contradictionary messages like 

      Error compiling qml file: /home/prcs1076/tmp/loader/Foo.qml:4:43: error: Type annotations are not supported (yet).
      [12/21 112.6/sec] Generating .rcc/qmlcache/apploader_main_qml.cpp
      Error: main.qml:9:5: Could not compile function grumble: Functions without type annotations won't be compiled
          function grumble(info, popup = true) {
          ^^^^^^^^^
      ninja: build stopped: subcommand failed.

      .

       

      Removing the = true works.

      Attachments

        1. loader.tgz
          1 kB
          Cajus Pollmeier

        Issue Links

          Activity

            People

              qtqmlteam Qt Qml Team User
              cajus Cajus Pollmeier
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated: