[vala/0.48] vala: Handle parameter initializer without value-type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] vala: Handle parameter initializer without value-type
- Date: Wed, 15 Jul 2020 07:11:12 +0000 (UTC)
commit 96830fa9ae978c88f9b0fb226cb56104e0d11378
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 99e4d5f6f..a2ac4958d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -588,6 +588,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/member-dup-destroy.vala \
generics/string-literal-comparison.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 0267a7675..339fd615c 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]