diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2019-01-08 16:27:56 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2019-07-09 16:52:01 +0200 |
commit | a06736cab722c2a4283cdcbda8d003d8e91d7f54 (patch) | |
tree | f083fe5bca85a06254e63729802d6c081c88cf87 /tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml | |
parent | d9f115327cd36cef370172bc87706cca6e57f912 (diff) |
Add basic type annotation support for QML functions to the grammar
Inspired by TypeScript syntax, allow optional type annotations in the
style of ": <name of type>" in for the parameters of functions and their
return type.
These annotations are not used at the moment, so by default we produce
an error message when encountering them in the AST.
In addition their usage is limited to functions declared in the QML
scope. All other uses attempt to produce readable syntax errors. So for
example this is okay:
Item {
function blah(param: string) string { ... }
}
And this is not okay:
// some file.js
function blah(param: string) : string { ... }
Change-Id: I12d20b4e2ce92e01108132975a06cfd13ba4a254
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml')
-rw-r--r-- | tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml b/tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml new file mode 100644 index 0000000000..655fe4c226 --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/typeAnnotations.2.qml @@ -0,0 +1,8 @@ +import QtQml 2.0 + +QtObject { + function notYet() { + var x: string = "ko" + return x + } +} |