Skip to content

Commit 0366b05

Browse files
committed
Emit proper compile error while trying to #[export] Gd<T> or DynGd<T, D>.
1 parent 47cc8da commit 0366b05

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

godot-macros/src/class/derive_godot_class.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,14 @@ fn parse_fields(
680680
if let Some(mut parser) = KvParser::parse(&named_field.attributes, "export")? {
681681
let export = FieldExport::new_from_kv(&mut parser)?;
682682
field.export = Some(export);
683+
684+
if path_ends_with_complex(&field.ty, "Gd") || path_ends_with_complex(&field.ty, "DynGd")
685+
{
686+
return bail!(
687+
field.ty,
688+
"`Gd` and `DynGd` cannot be used directly as properties because they are non-nullable. Use `OnEditor<T>` or `Option<T>` instead."
689+
);
690+
}
683691
parser.finish()?;
684692
}
685693

0 commit comments

Comments
 (0)