[vala/staging] vala: Handle parameter initializer without value-type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Handle parameter initializer without value-type
- Date: Sat, 11 Jul 2020 17:07:13 +0000 (UTC)
commit c789ec5f4e93f746be6aa4d374374c497c150b70
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 9980e94bb..8cda2904c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -592,6 +592,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 986d451ab..d93dad324 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]