mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
Fix purity check for focus()
on custom component
Do the purity check before doing the transformation of the `focus()` function, so the source location of the error is the most accurate Fixes #6979
This commit is contained in:
parent
ae087629e9
commit
461beb80cd
3 changed files with 18 additions and 1 deletions
|
@ -289,9 +289,9 @@ pub fn run_import_passes(
|
|||
) {
|
||||
infer_aliases_types::resolve_aliases(doc, diag);
|
||||
resolving::resolve_expressions(doc, type_loader, diag);
|
||||
purity_check::purity_check(doc, diag);
|
||||
focus_handling::replace_forward_focus_bindings_with_focus_functions(doc, diag);
|
||||
check_expressions::check_expressions(doc, diag);
|
||||
purity_check::purity_check(doc, diag);
|
||||
check_rotation::check_rotation(doc, diag);
|
||||
unique_id::check_unique_id(doc, diag);
|
||||
}
|
||||
|
|
|
@ -58,6 +58,7 @@ pub fn replace_forward_focus_bindings_with_focus_functions(
|
|||
arg_names: vec![],
|
||||
})),
|
||||
visibility: PropertyVisibility::Public,
|
||||
pure: Some(false),
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
|
|
16
internal/compiler/tests/syntax/fuzzing/6979.slint
Normal file
16
internal/compiler/tests/syntax/fuzzing/6979.slint
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
||||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
||||
|
||||
component SubElement {
|
||||
forward_focus: input;
|
||||
input := TextInput { }
|
||||
}
|
||||
|
||||
export component TestCase {
|
||||
pure callback focus_input2();
|
||||
focus_input2 => {
|
||||
input2.focus();
|
||||
// ^error{Call of impure function}
|
||||
}
|
||||
input2 := SubElement { }
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue