Parser: Hint for the mod function when parsing %

Was reported several times:
 - https://github.com/slint-ui/slint/discussions/4190
 - https://github.com/slint-ui/slint/issues/3980
This commit is contained in:
Olivier Goffart 2023-12-19 16:03:53 +01:00
parent 2404cce0bc
commit 2ce161ced8
2 changed files with 18 additions and 0 deletions

View file

@ -0,0 +1,12 @@
// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial
component Foo {
property <int> abc: 45 %;
// ^error{Unexpected '%'. For the unit, it should be attached to the number. If you're looking for the modulo operator, use the 'Math.mod\(x, y\)' function}
property <int> def: abc % 8;
// ^error{Unexpected '%'. For the unit, it should be attached to the number. If you're looking for the modulo operator, use the 'Math.mod\(x, y\)' function}
// ^^error{Parse error}
}