Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-26163

Qt Creator is overdoing type inference

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • Qt Creator 4.15.2
    • Quick / QML Support
    • None
    • All

    Description

      Summary

      Qt Creator shows red error annotation about expected types of a generic var property binding, when it's actually not an error, but at most a soft warning.

      Steps to reproduce

      1. Create a QML component, and add a var property to it, e.g. property var con.
      2. Bind a primitive value to it right at the declaration, e.g. property var con: "Yahaha!"
      3. In another component, instantiate that component defined in step 1.
      4. Bind to that property a value of a different primitive type, e.g. con: 42.

      Expected result

      No errors. At most a warning, but I'd prefer nothing at all.

      Actual result

      String value expected. (M5)

      Side note

      I found it hard to reproduce. Seems to trigger consistently with string/int pairs.

      Maybe it's not actually an imaginary type inference, but just a cached property type? Maybe then, the cache uses names as an index/key, so changes to types may not get propagated immediately?

      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
            ratijas ivan tkachenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes