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

QML – Inconsistent behavior when annotating functions

XMLWordPrintable

    • Linux/Wayland

      I noticed some weird behaviour when annotating functions inside an Item and inside a another function. I wasn't find any reference in the wiki mentioning this behaviour. When annotating a parameter without also annotating the return type following error is logged:

      Error: $FILENAME $VALUE should be coerced to void because the function called is insufficiently annotated. The original value is retained. This will change in a future version of Qt.

      However if a function declaration inside a function annotates a function parameter annotating the return type does not resolve this issue. Below is an example that illustrates the behaviour:

      Item
      {
          function test0(layerIndex) // fine
          { return 0; }
      
          function test1(layerIndex : int) // not fine
          { return 0; }
      
          function test2(layerIndex) : int // fine
          { return 0; }
      
          function test3(layerIndex : int) : int // fine
          { return 0; }
      
          Component.onCompleted: {
      
              function test4(layerIndex) // fine
              { return 0; }
      
              function test5(layerIndex) : int // fine
              { return 0; }
      
              function test6(layerIndex : int) // not fine
              { return 0; }
      
              function test7(layerIndex : int) : int // not fine
              { return 0; }
      
              var x = 0;
              x = test0();
              x = test1(); // fail
              x = test2();
              x = test3();
              x = test4();
              x = test5();
              x = test6(); // fail
              x = test7(); // fail
          }
      }
      

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

            qtqmlteam Qt Qml Team User
            jsentity Timur Vaydogan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes