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

qmllint gives 'can be shadowed' warning first time accessing property of aliased item

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.10
    • 6.3.1
    • QML: Tooling

    Description

      With the following files I get this warning:

      /usr/lib/qt6/bin/qmllint --compiler warning Test.qml
       Warning: Test.qml:6:16: Could not compile binding for onCompleted: Member someProp of QString of QString can be shadowed
       idRoot.idTest.someProp = "test"
      

      Test.qml

      import QtQuick
      
      TestForm {
          id: idRoot
          Component.onCompleted: {
              idRoot.idTest.someProp = "test"
              idRoot.idTest.otherProp = "test2"
          }
      }
      

      TestForm.ui.qml

      import QtQuick
      
      Item {
          property alias idTest: idTestComponent
      
          TestComponent {
              id: idTestComponent
          }
      }
      

      TestComponent.qml

      import QtQuick
      
      Item {
          property string someProp
          property string otherProp
      }
      

      If I add '// qmllint disable' to the first assignment line in Test.qml, I do not get an error for the second line.

      Moving Component.onComplete into TestForm.ui.qml silences the shadowing warning.

      Qmllint seems to be aware of the properties though, as adding something like 'idRoot.idTest.badprop = "bad"' will give another warning and silence the shadowing warning.

      The initial warning it self also seems a bit dubious as TestComponent is not a QString. 

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            knutt Knut Tidemann
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes