-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check validity of the format string at compile time
- Loading branch information
Showing
2 changed files
with
109 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial | ||
|
||
export component X { | ||
property <string> t1: @tr("fo{}oo", 42px); | ||
// ^error{Cannot convert length to string. Divide by 1px to convert to a plain number} | ||
property <string> t2: @tr("foo{0️⃣}bar", 45); | ||
// ^error{Invalid '\{...\}' placeholder in format string. The placeholder must be a number, or braces must be escaped with '\{\{' and '\}\}'} | ||
property <string> t6: @tr("foo{", 45); | ||
// ^error{Unterminated placeholder in format string. '\{' must be escaped with '\{\{'} | ||
property <string> t7: @tr("foo{bar", 45); | ||
// ^error{Unterminated placeholder in format string. '\{' must be escaped with '\{\{'} | ||
property <string> t8: @tr("foo{bar}bar", 45); | ||
// ^error{Invalid '\{...\}' placeholder in format string. The placeholder must be a number, or braces must be escaped with '\{\{' and '\}\}'} | ||
property <string> t9: @tr("foo{}bar"); | ||
// ^error{Format string contains 1 placeholders, but only 0 extra arguments were given} | ||
property <string> t10: @tr("foo{}ba{}r", 42); | ||
// ^error{Format string contains 2 placeholders, but only 1 extra arguments were given} | ||
property <string> t11: @tr("foo{65535}ba{2147483647}r"); | ||
// ^error{Invalid '\{...\}' placeholder in format string. The placeholder must be a number, or braces must be escaped with '\{\{' and '\}\}'} | ||
// ^^error{Format string contains 65536 placeholders, but only 0 extra arguments were given} | ||
property <string> t12: @tr("foo{45}bar", 44); | ||
// ^error{Format string contains 46 placeholders, but only 1 extra arguments were given} | ||
property <string> t13: @tr("foo{0}ba{}r", 44, 42); | ||
// ^error{Cannot mix positional and non-positional placeholder in format string} | ||
property <string> t14: @tr("foo{}ba{1}r", 44, 42); | ||
// ^error{Cannot mix positional and non-positional placeholder in format string} | ||
property <string> t15: @tr("fooba🥸{3}🥸r", 44, 42, 45); | ||
// ^error{Format string contains 4 placeholders, but only 3 extra arguments were given} | ||
property <string> t16: @tr("foo{} {}ba{}r", 44, 42); | ||
// ^error{Format string contains 3 placeholders, but only 2 extra arguments were given} | ||
property <string> t17: @tr("fo{}o}r", 44, 42); | ||
// ^error{Unescaped '\}' in format string. Escape '\}' with '\}\}'} | ||
|
||
|
||
} |