[vala/0.46] vala: Handle parameter initializer without value-type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Handle parameter initializer without value-type
- Date: Thu, 30 Jul 2020 11:03:07 +0000 (UTC)
commit 545a077e1228ffc0a9dcb1234fe60ec1a7db8fd2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jul 11 19:06:04 2020 +0200
vala: Handle parameter initializer without value-type
This caused criticals like:
vala_data_type_compatible: assertion 'self != NULL' failed
See https://gitlab.gnome.org/GNOME/vala/issues/1029
tests/Makefile.am | 1 +
tests/generics/parameter-invalid-initializer.test | 8 ++++++++
vala/valaparameter.vala | 3 +++
3 files changed, 12 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4f12d128b..2ed899e7d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -564,6 +564,7 @@ TESTS = \
generics/inference-argument-may-fail.vala \
generics/inference-static-function.vala \
generics/integer-type-cast.vala \
+ generics/parameter-invalid-initializer.test \
generics/parameter-sizeof-initializer.vala \
generics/string-literal-comparison.vala \
generics/type-parameter-properties.vala \
diff --git a/tests/generics/parameter-invalid-initializer.test
b/tests/generics/parameter-invalid-initializer.test
new file mode 100644
index 000000000..d3b8b80d4
--- /dev/null
+++ b/tests/generics/parameter-invalid-initializer.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Class<G> {
+ public Class (Type type = G);
+}
+
+void main () {
+}
diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala
index fe7aabd6e..09c73ffa5 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -166,6 +166,9 @@ public class Vala.Parameter : Variable {
if (initializer != null) {
initializer.target_type = variable_type.copy ();
initializer.check (context);
+ if (initializer.value_type == null) {
+ initializer.value_type = new InvalidType ();
+ }
}
unowned ArrayType? variable_array_type = variable_type as ArrayType;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]