[vala/staging] vala: Bail ThrowStatement.get_error_types() if error is set
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Bail ThrowStatement.get_error_types() if error is set
- Date: Thu, 20 Feb 2020 13:27:08 +0000 (UTC)
commit fb4ddde169b7b80b6bd1ddb73b20d420e7b39160
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Feb 20 14:19:10 2020 +0100
vala: Bail ThrowStatement.get_error_types() if error is set
This caused criticals when error_expression is not correct.
tests/Makefile.am | 1 +
tests/semantic/throw-unknown-error-type.test | 14 ++++++++++++++
vala/valathrowstatement.vala | 3 +++
3 files changed, 18 insertions(+)
---
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<DataType> collection, SourceReference?
source_reference = null) {
+ if (error) {
+ return;
+ }
if (source_reference == null) {
source_reference = this.source_reference;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]