Fix compiler panic binding to property with syntax error (#6572)

Fixes #6519
This commit is contained in:
Olivier Goffart 2024-10-16 21:35:35 +02:00 committed by GitHub
parent 40faf0e1c4
commit 13d44130d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 0 deletions

View file

@ -1562,6 +1562,11 @@ fn resolve_two_way_bindings(
// Check the compatibility.
let mut rhs_lookup = nr.element().borrow().lookup_property(nr.name());
if rhs_lookup.property_type == Type::Invalid {
// An attempt to resolve this already failed when trying to resolve the property type
assert!(diag.has_errors());
continue;
}
rhs_lookup.is_local_to_component &=
lookup_ctx.is_local_element(&nr.element());

View file

@ -0,0 +1,19 @@
// 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 Button{
property<bool>checked
}
// ^error{Syntax error: expected ';'}
export component C{
in property<b in
// ^error{Syntax error: expected '>'}
Button {
// ^error{Syntax error: expected ';'}
checked<=>in obal
// ^error{Syntax error: expected ';'}
// ^^error{Parse error}
}
}

View file

@ -5,6 +5,7 @@ export component Button {
in property<bool> enabled : true;
out property <bool> pressed;
in-out property <bool> checked;
property <bool> internal;
callback clicked();
}
@ -304,6 +305,9 @@ export component C12 {
in property <bool> in5 <=> inout1;
// ^error{Cannot link input property}
in property <bool> boggus1 <=> btn.internal;
// ^error{The property 'internal' is private. Annotate it with}
in-out property <bool> inout1;
btn := Button {