[vala/0.48] codegen: Report error for missing type-arguments of HashTable (de)serialization
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] codegen: Report error for missing type-arguments of HashTable (de)serialization
- Date: Sun, 14 Mar 2021 15:47:45 +0000 (UTC)
commit 6229a78666ee8d7a0806deb5b4a3f8f48df24612
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Mar 7 17:19:01 2021 +0100
codegen: Report error for missing type-arguments of HashTable (de)serialization
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1147
codegen/valagvariantmodule.vala | 10 ++++++++--
tests/Makefile.am | 1 +
.../gvariants-hashtable-missing-type-arguments.test | 12 ++++++++++++
3 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valagvariantmodule.vala b/codegen/valagvariantmodule.vala
index bd45a7738..d4719b906 100644
--- a/codegen/valagvariantmodule.vala
+++ b/codegen/valagvariantmodule.vala
@@ -468,7 +468,10 @@ public class Vala.GVariantModule : GValueModule {
string value_name = "_tmp%d_".printf (next_temp_var_id++);
var type_args = type.get_type_arguments ();
- assert (type_args.size == 2);
+ if (type_args.size != 2) {
+ Report.error (type.source_reference, "Missing type-arguments for GVariant
deserialization of `%s'".printf (type.type_symbol.get_full_name ()));
+ return new CCodeInvalidExpression ();
+ }
var key_type = type_args.get (0);
var value_type = type_args.get (1);
@@ -785,7 +788,10 @@ public class Vala.GVariantModule : GValueModule {
string value_name = "_tmp%d_".printf (next_temp_var_id++);
var type_args = type.get_type_arguments ();
- assert (type_args.size == 2);
+ if (type_args.size != 2) {
+ Report.error (type.source_reference, "Missing type-arguments for GVariant
serialization of `%s'".printf (type.type_symbol.get_full_name ()));
+ return new CCodeInvalidExpression ();
+ }
var key_type = type_args.get (0);
var value_type = type_args.get (1);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e74a8ab39..d4b4fef16 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -58,6 +58,7 @@ TESTS = \
basic-types/glists.vala \
basic-types/gptrarray.vala \
basic-types/gvariants.vala \
+ basic-types/gvariants-hashtable-missing-type-arguments.test \
basic-types/gvariants-unboxing-safe.vala \
basic-types/null.vala \
basic-types/bug570846.test \
diff --git a/tests/basic-types/gvariants-hashtable-missing-type-arguments.test
b/tests/basic-types/gvariants-hashtable-missing-type-arguments.test
new file mode 100644
index 000000000..2ce71ded5
--- /dev/null
+++ b/tests/basic-types/gvariants-hashtable-missing-type-arguments.test
@@ -0,0 +1,12 @@
+Invalid Code
+
+void main () {
+ {
+ HashTable foo = null;
+ Variant v = foo;
+ }
+ {
+ Variant v = null;
+ var foo = (HashTable) v;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]