]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Bail ThrowStatement.get_error_types() if error is set
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 20 Feb 2020 13:19:10 +0000 (14:19 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 20 Feb 2020 13:19:10 +0000 (14:19 +0100)
This caused criticals when error_expression is not correct.

tests/Makefile.am
tests/semantic/throw-unknown-error-type.test [new file with mode: 0644]
vala/valathrowstatement.vala

index d4e3653537af19691666eac91e838c47af7f4b81..9d54c2ea0c67e19e02bf7a06eaac218fdcf47cd1 100644 (file)
@@ -874,6 +874,7 @@ TESTS = \
        semantic/switch-label-not-constant.test \
        semantic/switch-type-unsupported.test \
        semantic/throw-no-error-type.test \
+       semantic/throw-unknown-error-type.test \
        semantic/type-argument-ownership-mismatch.test \
        semantic/unary-unsupported-complement.test \
        semantic/unary-unsupported-increment.test \
diff --git a/tests/semantic/throw-unknown-error-type.test b/tests/semantic/throw-unknown-error-type.test
new file mode 100644 (file)
index 0000000..40834e8
--- /dev/null
@@ -0,0 +1,14 @@
+Invalid Code
+
+void foo () throws Error {
+       int bar = 1;
+       switch (bar) {
+               case 0:
+                       break;
+               default:
+                       throw new FooError.FAIL ("");
+       }
+}
+
+void main () {
+}
index 9349b18188cf3917a89c2f515c31a269211926be..4ba347a9bccc3a658ebd3719905526aef97d3990 100644 (file)
@@ -73,6 +73,9 @@ public class Vala.ThrowStatement : CodeNode, Statement {
        }
 
        public override void get_error_types (Collection<DataType> collection, SourceReference? source_reference = null) {
+               if (error) {
+                       return;
+               }
                if (source_reference == null) {
                        source_reference = this.source_reference;
                }