[vala/0.46] vala: Improve error message for arrays as type arguments
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Improve error message for arrays as type arguments
- Date: Wed, 30 Oct 2019 07:45:49 +0000 (UTC)
commit a81a71dcf0f80f9b707d3cae067463f10299d369
Author: Florian Brosch <flo brosch gmail com>
Date: Wed Sep 3 01:37:31 2014 +0200
vala: Improve error message for arrays as type arguments
codegen/valaccodebasemodule.vala | 2 ++
tests/Makefile.am | 1 +
tests/generics/arrays-not-supported.test | 8 ++++++++
3 files changed, 11 insertions(+)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index fccc80dbe..797c3bcb2 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4674,6 +4674,8 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
if (delegate_type.delegate_symbol.has_target) {
Report.error (type_arg.source_reference, "Delegates with target are not
supported as generic type arguments");
}
+ } else if (type_arg is ArrayType) {
+ Report.error (type_arg.source_reference, "Arrays are not supported as generic type
arguments");
} else {
Report.error (type_arg.source_reference, "`%s' is not a supported generic type
argument, use `?' to box value types".printf (type_arg.to_string ()));
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 301674152..5ebbd0389 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -491,6 +491,7 @@ TESTS = \
asynchronous/variadic-invalid.test \
asynchronous/variadic-invalid-2.test \
asynchronous/yield.vala \
+ generics/arrays-not-supported.test \
generics/constructor-chain-up.vala \
generics/inference-static-function.vala \
generics/parameter-sizeof-initializer.vala \
diff --git a/tests/generics/arrays-not-supported.test b/tests/generics/arrays-not-supported.test
new file mode 100644
index 000000000..39bce9001
--- /dev/null
+++ b/tests/generics/arrays-not-supported.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+void foo<G>(G g = null) {
+}
+
+void main () {
+ foo<int[]>();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]