Fix assertion failed: lhs_lookup.is_local_to_component

Fixes #6632
This commit is contained in:
Olivier Goffart 2024-10-28 10:45:08 +01:00
parent 89bc023819
commit dff19c52da
3 changed files with 36 additions and 3 deletions

View file

@ -1591,10 +1591,12 @@ fn resolve_two_way_bindings(
.or_default()
.is_linked = true;
if lhs_lookup.property_visibility == PropertyVisibility::Private
&& !lhs_lookup.is_local_to_component
if matches!(
lhs_lookup.property_visibility,
PropertyVisibility::Private | PropertyVisibility::Output
) && !lhs_lookup.is_local_to_component
{
// Assignment to private property should have been reported earlier
// invalid property assignment should have been reported earlier
assert!(diag.has_errors());
continue;
}

View file

@ -0,0 +1,9 @@
// 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
export component S{
t:=TextInput{
has-focus<=>t.has-focus;
// ^error{Cannot assign to output property 'has-focus'}
}
}

View file

@ -336,9 +336,31 @@ export component C13 {
// ^error{Cannot assign to private property 'internal'}
Button { internal <=> self.checked; }
// ^error{Cannot assign to private property 'internal'}
Button { pressed <=> self.pressed; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> self.checked; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> self.enabled; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> self.accessible-checked; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> self.internal; }
// ^error{Cannot assign to output property 'pressed'}
// ^^error{The property 'internal' is private. Annotate it with}
Button { pressed <=> out; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> in; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> inout; }
// ^error{Cannot assign to output property 'pressed'}
Button { pressed <=> priv; }
// ^error{Cannot assign to output property 'pressed'}
}
export Legacy1 := Rectangle {
// ^warning{':=' to declare a component is deprecated}
b1:= Button {}
in property in1 <=> b1.pressed;
// ^warning{Link to a output property is deprecated}