slint/internal/compiler/tests/syntax/functions/functions_call.slint
Simon Hausmann 24dcef5fed
First stage of cleaning up the export handling of the slint root component (#2095)
We implicitly export the last component of a .slint file to the generator.
Issue a warning when that happens and suggest to export it explicitly.
2023-01-23 15:19:49 +01:00

38 lines
950 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() {}
}
export 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{Binding to callback 'xx' must bind to another callback}
}