]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: check a property has an accessor and/or a mutator 6dfc56a54544a129e91d11202d5f1c5424d57dab
authorAlistair Thomas <astavale@yahoo.co.uk>
Tue, 8 Nov 2016 00:36:58 +0000 (00:36 +0000)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 8 Nov 2016 07:56:12 +0000 (08:56 +0100)
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=773956

tests/Makefile.am
tests/objects/bug773956-1.test [new file with mode: 0644]
tests/objects/bug773956-2.test [new file with mode: 0644]
vala/valaproperty.vala

index cfda178d911590ef1f6fec3e9157a9f32568d50d..d3c709a6b281f6bb1c940a784fcbe47107d5d860 100644 (file)
@@ -190,6 +190,8 @@ TESTS = \
        objects/bug760031.test \
        objects/bug767092.test \
        objects/bug768823.test \
+       objects/bug773956-1.test \
+       objects/bug773956-2.test \
        objects/bug615830-1.test \
        objects/bug615830-2.test \
        errors/errors.vala \
diff --git a/tests/objects/bug773956-1.test b/tests/objects/bug773956-1.test
new file mode 100644 (file)
index 0000000..94b1616
--- /dev/null
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo : Object {
+       public int bar {}
+}
+
+void main () {
+       new Foo ();
+}
+
diff --git a/tests/objects/bug773956-2.test b/tests/objects/bug773956-2.test
new file mode 100644 (file)
index 0000000..a0457af
--- /dev/null
@@ -0,0 +1,10 @@
+Invalid Code
+
+class Foo : Object {
+       private int bar {}
+}
+
+void main () {
+       new Foo ();
+}
+
index 9da3508ea6c859c3655e2a799cd4b8756683ba0e..19aad24be9de0ff727f9ef4feb0d471295a43c5c 100644 (file)
@@ -395,6 +395,12 @@ public class Vala.Property : Symbol, Lockable {
 
                property_type.check (context);
 
+               if (get_accessor == null && set_accessor == null) {
+                       error = true;
+                       Report.error (source_reference, "Property `%s' must have a `get' accessor and/or a `set' mutator".printf (get_full_name ()));
+                       return false;
+               }
+
                if (get_accessor != null) {
                        get_accessor.check (context);
                }