From: Luca Bruno Date: Wed, 15 Dec 2010 14:01:05 +0000 (+0100) Subject: dova: Report error if can't infer element type for list/set/map literals X-Git-Tag: 0.11.3~58 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c83f7f3e839604ed29ea3563f0fbc058818e9b19;p=thirdparty%2Fvala.git dova: Report error if can't infer element type for list/set/map literals --- diff --git a/vala/valalistliteral.vala b/vala/valalistliteral.vala index b8759d697..7438ca7d5 100644 --- a/vala/valalistliteral.vala +++ b/vala/valalistliteral.vala @@ -114,6 +114,12 @@ public class Vala.ListLiteral : Literal { } } + if (element_type == null) { + error = true; + Report.error (source_reference, "cannot infer element type for list literal"); + return false; + } + element_type = element_type.copy (); element_type.value_owned = true; list_type.add_type_argument (element_type); diff --git a/vala/valamapliteral.vala b/vala/valamapliteral.vala index 3d1170d99..e9eca0b5d 100644 --- a/vala/valamapliteral.vala +++ b/vala/valamapliteral.vala @@ -115,6 +115,18 @@ public class Vala.MapLiteral : Literal { } } + if (map_key_type == null) { + error = true; + Report.error (source_reference, "cannot infer key type for map literal"); + return false; + } + + if (map_value_type == null) { + error = true; + Report.error (source_reference, "cannot infer value type for map literal"); + return false; + } + map_key_type = map_key_type.copy (); map_key_type.value_owned = true; map_value_type = map_value_type.copy (); diff --git a/vala/valasetliteral.vala b/vala/valasetliteral.vala index d0f122891..bf10e0155 100644 --- a/vala/valasetliteral.vala +++ b/vala/valasetliteral.vala @@ -98,6 +98,12 @@ public class Vala.SetLiteral : Literal { } } + if (element_type == null) { + error = true; + Report.error (source_reference, "cannot infer element type for set literal"); + return false; + } + element_type = element_type.copy (); element_type.value_owned = true; set_type.add_type_argument (element_type);