From: Rico Tzschichholz Date: Thu, 20 Feb 2020 13:19:10 +0000 (+0100) Subject: vala: Bail ThrowStatement.get_error_types() if error is set X-Git-Tag: 0.47.92~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb4ddde169b7b80b6bd1ddb73b20d420e7b39160;p=thirdparty%2Fvala.git vala: Bail ThrowStatement.get_error_types() if error is set This caused criticals when error_expression is not correct. --- diff --git a/tests/Makefile.am b/tests/Makefile.am index d4e365353..9d54c2ea0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 000000000..40834e8c2 --- /dev/null +++ b/tests/semantic/throw-unknown-error-type.test @@ -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 () { +} diff --git a/vala/valathrowstatement.vala b/vala/valathrowstatement.vala index 9349b1818..4ba347a9b 100644 --- a/vala/valathrowstatement.vala +++ b/vala/valathrowstatement.vala @@ -73,6 +73,9 @@ public class Vala.ThrowStatement : CodeNode, Statement { } public override void get_error_types (Collection collection, SourceReference? source_reference = null) { + if (error) { + return; + } if (source_reference == null) { source_reference = this.source_reference; }