[vala/0.48] vala: Don't allow disposable SimpleType structs
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Don't allow disposable SimpleType structs
- Date: Sun, 28 Feb 2021 17:26:25 +0000 (UTC)
commit 6f59db1675475f33e31120f369d4c1c9a9006b1c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Jan 27 21:08:09 2021 +0100
vala: Don't allow disposable SimpleType structs
tests/Makefile.am | 1 +
tests/structs/simple-type-disposable.test | 9 +++++++++
vala/valastruct.vala | 4 ++++
3 files changed, 14 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b944c75d9..697a2c728 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -331,6 +331,7 @@ TESTS = \
structs/gmutex.vala \
structs/gvalue.vala \
structs/gvalue-implicit-comparison.vala \
+ structs/simple-type-disposable.test \
structs/bug530605.vala \
structs/bug572091.vala \
structs/bug583603.vala \
diff --git a/tests/structs/simple-type-disposable.test b/tests/structs/simple-type-disposable.test
new file mode 100644
index 000000000..68f64a98e
--- /dev/null
+++ b/tests/structs/simple-type-disposable.test
@@ -0,0 +1,9 @@
+Invalid Code
+
+[SimpleType]
+struct Foo {
+ public string s;
+}
+
+void main () {
+}
diff --git a/vala/valastruct.vala b/vala/valastruct.vala
index 53a952753..e297e48bd 100644
--- a/vala/valastruct.vala
+++ b/vala/valastruct.vala
@@ -457,6 +457,10 @@ public class Vala.Struct : TypeSymbol {
if (f.binding == MemberBinding.INSTANCE
&& f.get_attribute_bool ("CCode", "delegate_target", true)
&& f.variable_type.is_disposable ()) {
+ if (is_simple_type ()) {
+ error = true;
+ Report.error (f.source_reference, "[SimpleType] struct `%s' cannot
have owned heap-allocated fields".printf (get_full_name ()));
+ }
return true;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]