]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
dova: Report error if can't infer element type for list/set/map literals
authorLuca Bruno <lucabru@src.gnome.org>
Wed, 15 Dec 2010 14:01:05 +0000 (15:01 +0100)
committerLuca Bruno <lucabru@src.gnome.org>
Wed, 15 Dec 2010 14:01:25 +0000 (15:01 +0100)
vala/valalistliteral.vala
vala/valamapliteral.vala
vala/valasetliteral.vala

index b8759d6977ea955b327755327d95b9151356a00f..7438ca7d5c24896ae34944e7e3b17a9195e2b26a 100644 (file)
@@ -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);
index 3d1170d991964bed2d40521b57666b4ff873eb23..e9eca0b5db9b0ecba0d2395d309ec74913d8b7ea 100644 (file)
@@ -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 ();
index d0f1228912e09c558aa62f96b18f46bc3a3ac8df..bf10e015556cf8ba1ce324e3d27b43ddda1de8d1 100644 (file)
@@ -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);