Function used before its declaration | Qt Qml | Qt 6.10.3
Description: [function-used-before-declaration] A function was used before its declaration.

- Qt 6.10
- Qt Qml
- QML Lint Warning and Errors
- Function used before its declaration
- Qt 6.10.3 Reference Documentation

# Function used before its declaration

This warning category is spelled `[function-used-before-declaration]` by qmllint.

This category is disabled by default.

## Function usage before its declaration

### What happened?

You called a function or used its name before the function was declared.

### Why is that bad?

It makes the code more difficult to read and may cause confusion.

Note that the function is made available before its declaration due to hoisting.

### Example

     import QtQuick

     Item {
         function f() {
             g(42)
             function g() { return 42; }
         }
     }

To fix this warning, move the declaration before the usage.

     import QtQuick

     Item {
         function f() {
             function g() { return 42; }
             g(42)
         }
     }