From b48e40a785bfd1b5a3d18bb9cb4009acb986dcc6 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 e1d3526a1..bf2e26c14 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 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