From fc734e56813ed2bb02fa2b80737d69a7789cf455 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Wed, 24 Jan 2018 14:40:34 +0100 Subject: [PATCH] vala: Variadic constructors without a real first parameter are not allowed --- tests/Makefile.am | 1 + tests/objects/constructor-variadic.test | 9 +++++++++ vala/valacreationmethod.vala | 6 ++++++ 3 files changed, 16 insertions(+) create mode 100644 tests/objects/constructor-variadic.test diff --git a/tests/Makefile.am b/tests/Makefile.am index a27e874dc..bd49e6771 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -184,6 +184,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 index 000000000..ed9527d99 --- /dev/null +++ b/tests/objects/constructor-variadic.test @@ -0,0 +1,9 @@ +Invalid Code + +class Foo { + Foo (...) { + } +} + +void main () { +} diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala index 451dd813d..4d905348f 100644 --- a/vala/valacreationmethod.vala +++ b/vala/valacreationmethod.vala @@ -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 ()) { -- 2.47.2