aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-04-18 19:42:45 +0300
committerVexu <git@vexu.eu>2020-04-18 23:56:03 +0300
commitfff00c3bbb9ed211f46eb1f1be07ebab84bc8d9d (patch)
tree9263b550d8beed693e8ef2ad930039bd50794917 /test/compile_errors.zig
parent6c907a350989aa881cc0b0f71ec81d1ae1b449b7 (diff)
downloadzig-fff00c3bbb9ed211f46eb1f1be07ebab84bc8d9d.tar.gz
zig-fff00c3bbb9ed211f46eb1f1be07ebab84bc8d9d.zip
disallow declarations between container fields
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index dfbb82edc6..6c120330e7 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -2,6 +2,21 @@ const tests = @import("tests.zig");
const std = @import("std");
pub fn addCases(cases: *tests.CompileErrorContext) void {
+ cases.add("declaration between fields",
+ \\const S = struct {
+ \\ a: usize,
+ \\ const foo = 2;
+ \\ const bar = 2;
+ \\ const baz = 2;
+ \\ b: usize,
+ \\};
+ \\comptime {
+ \\ _ = S;
+ \\}
+ , &[_][]const u8{
+ "tmp.zig:3:5: error: declarations are not allowed between container fields",
+ });
+
cases.add("non-extern function with var args",
\\fn foo(args: ...) void {}
\\export fn entry() void {