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

Linter reports false use before declaration warnings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • Qt Creator 7.0.2
    • Quick / QML Support

      Consider this function: 

      function reduceViewProductHistoryDetail(state, backend, actionCreator, data) {
          // Set the currently viewed event.
          // Search in active product live events first, then in product history.
      
          for (let i = 0; i < state.activeProductLiveEvents.count; ++i) {
              const e = state.activeProductLiveEvents.get(i)
              if (e.mid === data.id) {
                  state.detailEvent.fromJS(e)
                  actionCreator.redirect(Const.Page.ProductHistoryDetail)
                  return
              }
          }
          for (let i = 0; i < state.productHistory.count; ++i) {
              const e = state.productHistory.get(i)
              if (e.mid === data.id) {
                  state.detailEvent.fromJS(e)
                  actionCreator.redirect(Const.Page.ProductHistoryDetail)
                  return
              }
          }
      }
      

      The linter reports false positives for uses before declaration.

      When you remove the second for loop, no warnings get emitted.

      For the emitted warnings, see the attached screenshot

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

            qtqmlteam Qt Qml Team User
            skaldesh Sebastian Borchers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes