slint/internal/compiler/tests/syntax/functions/functions_call.slint

38 lines
929 B
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
Comp := Rectangle {
function f1() {}
public function f2() {}
}
Xxx := Rectangle {
function foo(a: int) -> string { return a; }
comp := Comp {}
function bar() {
foo(45, 45);
// ^error{The callback or function expects 1 arguments, but 2 are provided}
foo.hello(45);
// ^error{Cannot access fields of a function}
root.foo();
// ^error{The callback or function expects 1 arguments, but 0 are provided}
root.foo.hello(45);
// ^error{Cannot access fields of a function}
comp.f1();
// ^error{The function 'f1' is private. Annotate it with 'public' to make it accessible from other components}
comp.f2();
}
callback xx <=> foo;
// ^error{Cannot bind to a function}
}