宣言前に使用された関数
この警告カテゴリは、qmllint では「[function-used-before-declaration] 」と表記されます。
このカテゴリはデフォルトで無効になっています。
宣言前の関数の使用
何が起きたのか?
関数が宣言される前に、その関数を呼び出したり、その名前を使用したりしました。
なぜ問題なのでしょうか?
コードの可読性が低下し、混乱を招く恐れがあります。
なお、ホイスト現象により、関数は宣言される前に利用可能になります。
例
import QtQuick
Item {
function f() {
g(42)
function g() { return 42; }
}
}この警告を解消するには、宣言を使用箇所より前に移動してください。
import QtQuick
Item {
function f() {
function g() { return 42; }
g(42)
}
}© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.