]> 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>
Tue, 30 Jan 2018 07:14:17 +0000 (08:14 +0100)
tests/Makefile.am
tests/objects/constructor-variadic.test [new file with mode: 0644]
vala/valacreationmethod.vala

index e1d3526a1d4de78e71baf792bce000bad82d7a99..bf2e26c14d61a5099cab783eb431f619acac53f0 100644 (file)
@@ -148,6 +148,7 @@ TESTS = \
        delegates/bug792077.vala \
        objects/chainup.vala \
        objects/classes.vala \
+       objects/constructor-variadic.test \
        objects/constructors.vala \
        objects/fields.vala \
        objects/interfaces.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 ()) {