Skip to content

Commit

Permalink
Fix compiler panic binding to property with syntax error (#6572)
Browse files Browse the repository at this point in the history
Fixes #6519
  • Loading branch information
ogoffart authored Oct 16, 2024
1 parent 40faf0e commit 13d4413
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/compiler/passes/resolving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
19 changes: 19 additions & 0 deletions internal/compiler/tests/syntax/fuzzing/6519.slint
Original file line number Diff line number Diff line change
@@ -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}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 13d4413

Please sign in to comment.