mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
values: Don't allow assigning true/false to object
Fix a bug in the type checking code where it would not produce an error if you assigned "true" or "false" to an object property.
This commit is contained in:
parent
1e9b01bab9
commit
866092ccf7
3 changed files with 14 additions and 1 deletions
|
@ -338,7 +338,14 @@ class IdentLiteral(AstNode):
|
|||
raise CompileError(
|
||||
'"item" can only be used in an expression literal'
|
||||
)
|
||||
elif self.ident not in ["true", "false"]:
|
||||
elif self.ident in ["true", "false"]:
|
||||
if expected_type is not None and not isinstance(
|
||||
expected_type, gir.BoolType
|
||||
):
|
||||
raise CompileError(
|
||||
f"Cannot assign boolean to {expected_type.full_name}"
|
||||
)
|
||||
else:
|
||||
raise CompileError(
|
||||
f"Could not find object with ID {self.ident}",
|
||||
did_you_mean=(
|
||||
|
|
5
tests/sample_errors/convert_bool_to_obj.blp
Normal file
5
tests/sample_errors/convert_bool_to_obj.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
child: false;
|
||||
}
|
1
tests/sample_errors/convert_bool_to_obj.err
Normal file
1
tests/sample_errors/convert_bool_to_obj.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,5,Cannot assign boolean to Gtk.Widget
|
Loading…
Add table
Add a link
Reference in a new issue