slint/internal/compiler/tests/syntax/lookup/conversion.slint
Tobias Hunger 4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00

45 lines
2 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
global Glob := {
property <physical_length> len: 45px * 5;
// ^error{Cannot convert between logical and physical length in a global component, because the scale factor is not known}
property <length> logic_len: 45phx * 5;
// ^error{Cannot convert between logical and physical length in a global component, because the scale factor is not known}
property <float> ratio: allowed / 1phx;
// ^error{Cannot convert between logical and physical length in a global component, because the scale factor is not known}
property <float> should_work: 45px / 8px;
property <length> allowed: 45px * 5;
}
X := Rectangle {
t := Text {
x: "hello";
// ^error{Cannot convert string to length$}
text: 45;
}
Text {
x: t.text;
// ^error{Cannot convert string to length$}
y: 42;
// ^error{Cannot convert float to length. Use an unit, or multiply by 1px to convert explicitly}
text: x;
// ^error{Cannot convert length to string. Divide by 1px to convert to a plain number}
property<int> foo: y;
// ^error{Cannot convert length to int. Divide by 1px to convert to a plain number}
property<duration> bar: foo;
// ^error{Cannot convert int to duration. Use an unit, or multiply by 1ms to convert explicitly}
}
Rectangle {
background: "blue";
// ^error{Cannot convert string to brush$}
property<length> no_matching_parent: 50%;
// ^error{Automatic conversion from percentage to length is only possible for the properties width and height}
}
property <{a: string, b: int}> object1: { a: "123", typo: 42};
// ^error{Cannot convert \{ a: string,typo: float,\} to \{ a: string,b: int,\}}
}