From 2e74889c3ce61aae8e9e461d1f49a9b5cb79edc2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 24 Dec 2015 13:49:23 -0700 Subject: [PATCH] add test for invalid field in struct value expression --- test/run_tests.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/run_tests.cpp b/test/run_tests.cpp index f6a3c3dfe..9df395197 100644 --- a/test/run_tests.cpp +++ b/test/run_tests.cpp @@ -907,6 +907,21 @@ fn f() { }; } )SOURCE", 1, ".tmp_source.zig:8:15: error: missing field: 'x'"); + + add_compile_fail_case("invalid field in struct value expression", R"SOURCE( +struct A { + x : i32, + y : i32, + z : i32, +} +fn f() { + const a = A { + .z = 4, + .y = 2, + .foo = 42, + }; +} + )SOURCE", 1, ".tmp_source.zig:11:9: error: no member named 'foo' in 'A'"); } static void print_compiler_invocation(TestCase *test_case) {