| author | |
| committer | |
| log | 459d72f8736ebd8372b9050c17e5f3bc00092573 |
| tree | 989e276143fcc59055202f234c7d2209b69ab6d5 |
| parent | 5f38d6e2e97829ed74f06a96b5d07a2c68516063 |
closes #1079
closes #11472 files changed, 16 insertions(+), 2 deletions(-)
src/analyze.cpp+3-2| ... | ... | @@ -2318,8 +2318,9 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) { |
| 2318 | 2318 | return; |
| 2319 | 2319 | |
| 2320 | 2320 | if (enum_type->data.enumeration.zero_bits_loop_flag) { |
| 2321 | enum_type->data.enumeration.zero_bits_known = true; | |
| 2322 | enum_type->data.enumeration.zero_bits_loop_flag = false; | |
| 2321 | add_node_error(g, enum_type->data.enumeration.decl_node, | |
| 2322 | buf_sprintf("'%s' depends on itself", buf_ptr(&enum_type->name))); | |
| 2323 | enum_type->data.enumeration.is_invalid = true; | |
| 2323 | 2324 | return; |
| 2324 | 2325 | } |
| 2325 | 2326 |
test/compile_errors.zig+13| ... | ... | @@ -1,6 +1,19 @@ |
| 1 | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | |
| 3 | 3 | pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 4 | cases.add( | |
| 5 | "enum field value references enum", | |
| 6 | \\pub const Foo = extern enum { | |
| 7 | \\ A = Foo.B, | |
| 8 | \\ C = D, | |
| 9 | \\}; | |
| 10 | \\export fn entry() void { | |
| 11 | \\ var s: Foo = Foo.E; | |
| 12 | \\} | |
| 13 | , | |
| 14 | ".tmp_source.zig:1:17: error: 'Foo' depends on itself", | |
| 15 | ); | |
| 16 | ||
| 4 | 17 | cases.add( |
| 5 | 18 | "@floatToInt comptime safety", |
| 6 | 19 | \\comptime { |