]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Variadic constructors without a real first parameter are not allowed
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 24 Jan 2018 13:40:34 +0000 (14:40 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 24 Jan 2018 15:14:57 +0000 (16:14 +0100)
tests/Makefile.am
tests/objects/constructor-variadic.test [new file with mode: 0644]
vala/valacreationmethod.vala

index 54b0ae9720cd7268402f632efb4661a145bb727b..d92aae1308f17d7b81638b3acbf637bd64593170 100644 (file)
@@ -187,6 +187,7 @@ TESTS = \
        delegates/bug792077.vala \
        objects/chainup.vala \
        objects/classes.vala \
+       objects/constructor-variadic.test \
        objects/constructors.vala \
        objects/dynamic.vala \
        objects/generics.vala \
diff --git a/tests/objects/constructor-variadic.test b/tests/objects/constructor-variadic.test
new file mode 100644 (file)
index 0000000..ed9527d
--- /dev/null
@@ -0,0 +1,9 @@
+Invalid Code
+
+class Foo {
+       Foo (...) {
+       }
+}
+
+void main () {
+}
index 451dd813d7a88a07624072d3d38e72d81390e1f2..4d905348fd8de27833305896fa513304c52e475d 100644 (file)
@@ -99,8 +99,14 @@ public class Vala.CreationMethod : Method {
                }
                context.analyzer.current_symbol = this;
 
+               int i = 0;
                foreach (Parameter param in get_parameters()) {
                        param.check (context);
+                       if (i == 0 && param.ellipsis && body != null) {
+                               error = true;
+                               Report.error (param.source_reference, "Named parameter required before `...'");
+                       }
+                       i++;
                }
 
                foreach (DataType error_type in get_error_types ()) {