ability to specify tag type of enums

see #305
This commit is contained in:
Andrew Kelley
2017-11-30 21:46:02 -05:00
parent 5786df933d
commit b62e2fd870
11 changed files with 180 additions and 6 deletions

View File

@@ -2362,4 +2362,32 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
".tmp_source.zig:4:25: error: aoeu",
".tmp_source.zig:1:36: note: called from here",
".tmp_source.zig:12:20: note: referenced here");
cases.add("specify enum tag type that is too small",
\\const Small = enum (u2) {
\\ One,
\\ Two,
\\ Three,
\\ Four,
\\ Five,
\\};
\\
\\export fn entry() {
\\ var x = Small.One;
\\}
,
".tmp_source.zig:1:20: error: 'u2' too small to hold all bits; must be at least 'u3'");
cases.add("specify non-integer enum tag type",
\\const Small = enum (f32) {
\\ One,
\\ Two,
\\ Three,
\\};
\\
\\export fn entry() {
\\ var x = Small.One;
\\}
,
".tmp_source.zig:1:20: error: expected integer, found 'f32'");
}