authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-17 23:21:22-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-17 23:21:22-04:00
logdbc202cc6a3bcaffb2f6528551d6dd0a62a6b5a3
tree4666bd5fbe143025658b3280437530feabffe1cc
parentc5ca8b51f9151d24fd70686599b049749139e023

add test for struct with invalid field

see #468

1 files changed, 26 insertions(+), 0 deletions(-)

test/compile_errors.zig+26
......@@ -2127,4 +2127,30 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
21272127 ,
21282128 ".tmp_source.zig:2:33: error: expected type 'GlobalLinkage', found 'u32'");
21292129
2130 cases.add("struct with invalid field",
2131 \\const std = @import("std");
2132 \\const Allocator = std.mem.Allocator;
2133 \\const ArrayList = std.ArrayList;
2134 \\
2135 \\const HeaderWeight = enum {
2136 \\ H1, H2, H3, H4, H5, H6,
2137 \\};
2138 \\
2139 \\const MdText = ArrayList(u8);
2140 \\
2141 \\const MdNode = enum {
2142 \\ Header: struct {
2143 \\ text: MdText,
2144 \\ weight: HeaderValue,
2145 \\ },
2146 \\};
2147 \\
2148 \\export fn entry() {
2149 \\ const a = MdNode.Header {
2150 \\ .text = MdText.init(&std.debug.global_allocator),
2151 \\ .weight = HeaderWeight.H1,
2152 \\ };
2153 \\}
2154 ,
2155 ".tmp_source.zig:14:17: error: use of undeclared identifier 'HeaderValue'");
21302156}